Code: Select all
CLS
ECHO.
ECHO =============================
ECHO Running Admin shell
ECHO =============================
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (shift & goto gotPrivileges)
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************
setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
ECHO UAC.ShellExecute "!batchPath!", "ELEV", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%temp%\OEgetPrivileges.vbs"
exit /B
:gotPrivileges
setlocal & pushd %~dp0
REM Options Tab
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v QuickEdit /t REG_DWORD /d 0x00000001 /f
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v InsertMode /t REG_DWORD /d 0x00000001 /f
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v HistoryBufferSize /t REG_DWORD /d 0x000003e7 /f
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v NumberOfHistoryBuffers /t REG_DWORD /d 0x00000005 /f
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v HistoryNoDup /t REG_DWORD /d 0x00000000 /f
REM Font Tab
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v FaceName /t REG_SZ /d Consolas /f
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v FontFamily /t REG_DWORD /d 0x00000036 /f
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v FontSize /t REG_DWORD /d 0x000e0000 /f
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v FontWeight /t REG_DWORD /d 0x00000190 /f
REM Layout Tab
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v ScreenBufferSize /t REG_DWORD /d 0x270f00b4 /f
REG ADD "HKCU\Console\%%SystemRoot%%_system32_cmd.exe" /v WindowSize /t REG_DWORD /d 0x001e00b4 /f
FOR /F "skip=1 tokens=1,2,* delims= " %%I IN ('qwinsta console') DO SET currentuser=%%J
set "home=C:\Users\%currentuser%"
doskey /exename=cmd.exe cd=cd /d $*
doskey /exename=cmd.exe ls=dir/b
doskey /exename=cmd.exe tc=ping 8.8.8.8 -t
doskey /exename=cmd.exe rdp=mstsc.exe /v:$1 /f
doskey /exename=cmd.exe note=notepad.exe
doskey /exename=cmd.exe print=notepad.exe C:\Windows\System32\drivers\etc\hosts
doskey /exename=cmd.exe reboot=shutdown -r -t 0 -f
doskey /exename=cmd.exe shutdown=shutdown -s -t 0 -f
doskey /exename=cmd.exe ~=cd /d "%home%\Desktop"
cmd /k cls
The expected resut is to be able to set the new settings, run as administrator, and refresh the default CMD window to the new width, height, Quick Edit mode set in the script.
Any insight?
Thank you