Skip to content

Commit bd2ddd7

Browse files
authored
Added scripts
1 parent 7b75919 commit bd2ddd7

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

install-reg.bat

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
@echo off
2+
set cr=%~dp0
3+
set out=%cr%out
4+
5+
for /F "tokens=*" %%g IN (
6+
'REG QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path'
7+
) do (set curPath=%%g)
8+
echo %curPath% | grep -Eo "([^ ]+ {4}){2}" > %out%
9+
for /F "tokens=*" %%g IN ('cat %out%') do (set cpCut=%%g)
10+
echo %curPath% | sed -e "s/^%cpCut%//" > %out%
11+
for /F "tokens=*" %%g IN ('cat %out%') do (set curPath=%%g)
12+
set curPath=%curPath:~0,-1%
13+
del /f %out%
14+
15+
echo Creating context menu and variable registry intaller ...
16+
17+
set crp=%cr:\=\\%
18+
for /F "tokens=*" %%g IN ('where cmd') do (SET cmdp=%%g)
19+
set cmdp=%cmdp:\=\\%
20+
set ccr=%cr:~0,-1%
21+
set ccr=%ccr:\=\\%
22+
set curPathP=%curPath:\=\\%
23+
24+
echo Creating cmd-cmder script ...
25+
26+
set ccs=%cr%\cmd-cmder.bat
27+
28+
echo @echo off > %ccs%
29+
echo cmd /k "%cr%vendor\init.bat" >> %ccs%
30+
31+
echo Creating context menu registry intaller ...
32+
33+
set reg_file="%cr%CmderCM.reg"
34+
35+
echo Windows Registry Editor Version 5.00 > %reg_file%
36+
echo. >> %reg_file%
37+
echo [HKEY_CLASSES_ROOT\Directory\Background\shell\Cmder] >> %reg_file%
38+
echo @="Open Cmder Here" >> %reg_file%
39+
echo "Icon"="\"%crp%\\icons\\cmder.ico\",0" >> %reg_file%
40+
echo. >> %reg_file%
41+
echo [HKEY_CLASSES_ROOT\Directory\Background\shell\Cmder\command] >> %reg_file%
42+
echo @="\"%crp%\\Cmder.exe\" /start \"%%v\"" >> %reg_file%
43+
echo. >> %reg_file%
44+
echo [HKEY_CLASSES_ROOT\Directory\Background\shell\cmd-cmd] >> %reg_file%
45+
echo @="Open Terminal Here" >> %reg_file%
46+
echo "Icon"="\"%cmdp%\"" >> %reg_file%
47+
echo. >> %reg_file%
48+
echo [HKEY_CLASSES_ROOT\Directory\Background\shell\cmd-cmd\command] >> %reg_file%
49+
echo @="\"%cmdp%\"" >> %reg_file%
50+
echo. >> %reg_file%
51+
echo [HKEY_CLASSES_ROOT\Directory\Background\shell\cmd-cmder] >> %reg_file%
52+
echo @="Open Cmder terminal Here" >> %reg_file%
53+
echo "Icon"="\"%cmdp%\"" >> %reg_file%
54+
echo. >> %reg_file%
55+
echo [HKEY_CLASSES_ROOT\Directory\Background\shell\cmd-cmder\command] >> %reg_file%
56+
echo @="cmd /k \"%crp%\\vendor\\init.bat\"" >> %reg_file%
57+
echo. >> %reg_file%
58+
echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment] >> %reg_file%
59+
echo "CMDER_ROOT"="%ccr%" >> %reg_file%
60+
echo %curPath% | findstr /C:"C:\Cmder" > nul
61+
if %errorLevel% EQU 0 (
62+
echo -- Path variable already set.
63+
) else (
64+
echo "Path"="%curPathP%%ccr%;" >> %reg_file%
65+
)
66+
67+
echo Running registry intaller ...
68+
69+
regedit.exe /S %reg_file%
70+
71+
echo Cleanup ...
72+
73+
del /f %reg_file%
74+
75+
echo.
76+
pause

install.bat

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@echo off
2+
3+
net session >nul 2>&1
4+
if %errorLevel% EQU 0 (
5+
echo Running with administrator privileges...
6+
) else (
7+
echo Failure: Administrator privileges are required.
8+
goto error
9+
)
10+
11+
set cr=%~dp0
12+
echo Checking direcory ...
13+
14+
set cmderExe="%cr%Cmder.exe"
15+
set initBat="%cr%vendor\init.bat"
16+
17+
if exist %cmderExe% (
18+
if exist %initBat% (
19+
echo -- Success: is Cmder direcory
20+
goto install
21+
) else (
22+
goto dep_fail
23+
)
24+
) else (
25+
goto dep_fail
26+
)
27+
:dep_fail
28+
echo -- Failure: Script must be run in Cmder directory.
29+
goto error
30+
31+
:install
32+
echo Running install ...
33+
34+
set CMDER_ROOT=%cr%
35+
start cmd /k "%CMDER_ROOT%\vendor\init.bat cd %cr% && install-cmder.bat && exit"
36+
exit
37+
38+
:error
39+
echo.
40+
pause

0 commit comments

Comments
 (0)