日常更新,个性化未生效的情况下会再次启动,直至生效。
capi与image3共存,保留关闭最大最小及还原菜单。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
@echo off&rem http://blog.snote.cn/batheader/ if not "%1"=="" (mode con cols=%1 lines=%2&goto RegEnd)>nul title Init…&setlocal enabledelayedexpansion&set /a Col=64,Row=30 echo,var screen = new ActiveXObject("HTMLFile").parentWindow.screen;+WScript.Echo(screen.width + ' ' + screen.height);>%temp%\T.Js for /f "tokens=1,2 delims= " %%a in ('cscript //nologo //e:jscript %temp%\T.Js') do (set ScrW=%%a&set ScrH=%%b)&del %temp%\T.Js set F=0123456789ABCDEF&set /a WinW=Col*8+20,WinH=Row*16+44,PosL=(ScrW-WinW)/2,PosT=(ScrH-WinH)/2,"PosD=PosT<<16|PosL" :D2H set /a mod = %PosD% %% 16,PosD /=16 set en=%mod% %en% if not %PosD% lss 1 (goto D2H)&set PosH= for %%i in (%en%) do (call set PosH=!PosH!%%F:~%%i,1%%) (for %%a in ( CodePage:000001b5 QuickEdit:00000000 InsertMode:00000000 CursorSize:00000019 FontFamily:00000000 FontWeight:00000000 FontSize:00100008 WindowSize:001e0040 WindowPosition:%PosH% ColorTable00:00000000 ScreenBufferSize:001e0040 ) do (for /f "tokens=1,2 delims=:" %%b in ("%%a") do (reg add HKCU\Console\SanGod /v %%b /t REG_DWORD /d 0x%%c /f)) reg add HKCU\Console\SanGod /v FaceName /d Terminal /f reg query HKEY_CURRENT_USER\Console /v ForceV2&&for /f "tokens=3" %%a in ('reg query HKEY_CURRENT_USER\Console /v ForceV2') do (set V2=%%a reg add HKEY_CURRENT_USER\Console /v ForceV2 /t REG_DWORD /d 0x00000000 /f)&ping -n 2 localhost)>nul start /d "%~dps0" /i "SanGod" "%~dps0Tools\cmd.exe" /k %~fs0 %Col% %Row% (ping -n 1 localhost&if not "%V2%"=="" reg add HKEY_CURRENT_USER\Console /v ForceV2 /t REG_DWORD /d %V2% /f reg delete HKCU\Console\SanGod /f&exit)>nul :RegEnd setlocal enabledelayedexpansion for /f "tokens=1-2" %%a in ('mode con') do ( if /i "%%a"=="Lines:" set Row=%%~b if /i "%%a"=="Columns:" set Col=%%~b) if not "%Col%x%Row%"=="%1x%2" ( start /d "%~dps0" /i "SanGod" "%~dps0Tools\cmd.exe" /k %~fs0 exit) else (chcp 936)>nul set image=size cmd 512 480 if "%image%"=="size cmd 512 480" echo Image.dll failed to load set CAPI=CAPIDll Ver if "%CAPI_Ret%"=="" (echo CAPI.dll is not loaded&endlocal&goto InitEnd) (set CAPI=Mem Alloc 20&set lpIR=!CAPI_Ret!&set CAPI=Mem Alloc 4&set lpData=!CAPI_Ret!&set CAPI=API Call kernel32 GetStdHandle ;-10&set hIn=!CAPI_Ret!&set CAPI=API Call kernel32 GetStdHandle ;-11&set hOut=!CAPI_Ret! set CAPI=Mem Alloc 8&set lpCCI=!CAPI_Ret!&set CAPI=Mem Put ;!lpCCI! ;100&set CAPI=API Call kernel32 SetConsoleCursorInfo ;!hOut! ;!lpCCI!&set CAPI=Mem Free !lpCCI!&set CAPI=API Call user32 LoadImageW ;0 $Graphics\desktop.ico ;1 ;0 ;0 ;16&set hIco_cmd=!CAPI_Ret!&set CAPI=API Call kernel32 SetConsoleIcon ;!hIco_cmd! set CAPI=API Call kernel32 GetConsoleWindow&set hCMD=!CAPI_Ret!&set CAPI=Mem Alloc 16&set lpRC=!CAPI_Ret!&set CAPI=API Call user32 GetWindowRect ;!hCMD! ;!lpRC!&set CAPI=Mem Print ;!lpRC! ;xLeft ;yTop ;xRight ;yBottom&set /a xWidth=xRight-xLeft,yHeight=yBottom-yTop&set CAPI=API Call user32 ScreenToClient ;!hCMD! ;!lpRC!&set CAPI=Mem Print ;!lpRC! ;xWnd ;yWnd&set /a xWnd=-xWnd,yWnd=-yWnd&set CAPI=API Call user32 GetDesktopWindow&set CAPI=API Call user32 GetClientRect ;!CAPI_Ret! ;!lpRC!&set CAPI=Mem Print ;!lpRC! @8 ;xScreen ;yScreen&set /a xPos=xScreen-xWidth,xPos/=2,yPos=yScreen-yHeight,yPos/=2&set CAPI=API Call user32 MoveWindow ;!hCMD! ;!xPos! ;!yPos! ;!xWidth! ;!yHeight! ;1&set CAPI=Mem Free !lpRC! set CAPI=API Call kernel32 ConsoleMenuControl ;!hOut! ;501 ;504&set hMenu=!CAPI_Ret!&set CAPI=API Call user32 GetMenuItemCount ;!hMenu!&for /l %%a in (!CAPI_Ret!,-1,1) do ( if "%%a" lss "2" (set CAPI=API Call user32 GetMenuItemID ;!hMenu! ;%%a&if "!CAPI_Ret!" neq "61536" set CAPI=API Call user32 DeleteMenu ;!hMenu! ;%%a ;1024) if "%%a" gtr "5" (set CAPI=API Call user32 GetMenuItemID ;!hMenu! ;%%a&if "!CAPI_Ret!" neq "61536" set CAPI=API Call user32 DeleteMenu ;!hMenu! ;%%a ;1024))) endlocal :InitEnd |
再添加新版,依然结合CAPIx!
更加无残留,连用过的变量也不留……
这一次变化的话嘛……取消了管理员权限,两次居中修整,像标使用CAPIx更改旧版CMD完成,CAPIx屏蔽了右键菜单多余选项,关了光标,固定了窗口大小。放入image.dll可以直接使用……不兼容XP,以后不考虑XP了。代码行数减少50%
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
@echo off if not "%1"=="" (Mode %1,%2& chcp 936& cd /d "%~dps0"& goto RegEnd)>nul title Init…& set /a Col=64,Row=30& setlocal enabledelayedexpansion echo,var screen = new ActiveXObject("HTMLFile").parentWindow.screen;+WScript.Echo(screen.width + ' ' + screen.height);>%temp%\T.Js for /f "tokens=1,2 delims= " %%a in ('cscript //nologo //e:jscript %temp%\T.Js') do (set ScrW=%%a& set ScrH=%%b)& del %temp%\T.Js set F=0123456789ABCDEF& set /a WinW=Col*8+20,WinH=Row*16+44,PosL=(ScrW-WinW)/2,PosT=(ScrH-WinH)/2,"PosD=PosT<<16|PosL" :D2H set /a mod = %PosD% %% 16,PosD /=16 set en=%mod% %en% if not %PosD% lss 1 (goto D2H)& set PosH= for %%i in (%en%) do (call set PosH=!PosH!%%F:~%%i,1%%) (for %%a in ( CodePage:000001b5 QuickEdit:00000000 InsertMode:00000000 CursorSize:00000019 FontFamily:00000000 FontWeight:00000000 FontSize:00100008 WindowSize:001e0040 WindowPosition:%PosH% ColorTable00:00000000 ScreenBufferSize:001e0040 ) do (for /f "tokens=1,2 delims=:" %%b in ("%%a") do (reg add HKCU\Console\SanGod /v %%b /t REG_DWORD /d 0x%%c /f)) reg add HKCU\Console\SanGod /v FaceName /d Terminal /f reg query HKEY_CURRENT_USER\Console /v ForceV2 && for /f "tokens=3" %%a in ('reg query HKEY_CURRENT_USER\Console /v ForceV2') do ( reg add HKEY_CURRENT_USER\Console /v ForceV2 /t REG_DWORD /d 0x00000000 /f set V2=%%a) ping -n 1 localhost)>nul 2>nul start /i "SanGod" "%~dps0Tools\cmd.exe" /c %~fs0 %Col% %Row% (ping -n 1 localhost if not "%V2%"=="" reg add HKEY_CURRENT_USER\Console /v ForceV2 /t REG_DWORD /d %V2% /f reg delete HKCU\Console\SanGod /f exit)>nul :RegEnd setlocal enabledelayedexpansion set image=size cmd 512 480 if "%image%"=="size cmd 512 480" ( echo Image.dll is not loaded ping -n 5 localhost >nul &exit) set CAPI=CAPIDll Ver if "%CAPI_Ret%"=="" ( echo CAPI.dll is not loaded ENDLOCAL &goto InitEnd) set "Return_Choice=1"&set "Screen_UI_Message="&set CAPI=Mem Alloc 20&set lpIR=!CAPI_Ret!&set CAPI=Mem Alloc 4&set lpData=!CAPI_Ret!&set CAPI=API Call kernel32 GetStdHandle ;-10&set hIn=!CAPI_Ret!&set CAPI=API Call kernel32 GetStdHandle ;-11&set hOut=!CAPI_Ret! set CAPI=Mem Alloc 8&set lpCCI=!CAPI_Ret!&set CAPI=Mem Put ;!lpCCI! ;100&set CAPI=API Call kernel32 SetConsoleCursorInfo ;!hOut! ;!lpCCI!&set CAPI=Mem Free !lpCCI!&set CAPI=API Call user32 LoadImageW ;0 $Graphics\desktop.ico ;1 ;0 ;0 ;16&set hIco_cmd=!CAPI_Ret!&set CAPI=API Call kernel32 SetConsoleIcon ;!hIco_cmd! set CAPI=API Call kernel32 GetConsoleWindow&set hCMD=!CAPI_Ret!&set CAPI=Mem Alloc 16&set lpRC=!CAPI_Ret!&set CAPI=API Call user32 GetWindowRect ;!hCMD! ;!lpRC!&set CAPI=Mem Print ;!lpRC! ;xLeft ;yTop ;xRight ;yBottom&set /a xWidth=xRight-xLeft,yHeight=yBottom-yTop&set CAPI=API Call user32 ScreenToClient ;!hCMD! ;!lpRC!&set CAPI=Mem Print ;!lpRC! ;xWnd ;yWnd&set /a xWnd=-xWnd,yWnd=-yWnd&set CAPI=API Call user32 GetDesktopWindow&set CAPI=API Call user32 GetClientRect ;!CAPI_Ret! ;!lpRC!&set CAPI=Mem Print ;!lpRC! @8 ;xScreen ;yScreen&set /a xPos=xScreen-xWidth,xPos/=2,yPos=yScreen-yHeight,yPos/=2&set CAPI=API Call user32 MoveWindow ;!hCMD! ;!xPos! ;!yPos! ;!xWidth! ;!yHeight! ;1&set CAPI=Mem Free !lpRC! set CAPI=API Call kernel32 ConsoleMenuControl ;!hOut! ;501 ;504&set hMenu=!CAPI_Ret!&set CAPI=API Call user32 GetMenuItemCount ;!hMenu!&(for /l %%a in (!CAPI_Ret!,-1,0) do (set CAPI=API Call user32 GetMenuItemID ;!hMenu! ;%%a&if "!CAPI_Ret!" neq "61536" set CAPI=API Call user32 DeleteMenu ;!hMenu! ;%%a ;1024)) ENDLOCAL :InitEnd |
以下为旧版,结合CAPIx!
更加无残留,连用过的变量都不留……
变化的话嘛……拿了管理员权限,两次居中修整,像标使用CAPIx更改旧版CMD完成,CAPIx屏蔽了右键菜单多余选项,关了光标,固定了窗口大小。放入image.dll可以直接使用……不兼容XP了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
@echo off if not "%2"=="" ( Mode %2,%3 REM chcp 936 >nul cd /d "%~dps0" goto RegEnd ) %1mshta vbscript:CreateObject("Shell.Application").ShellExecute("%ComSpec%","/v:on /c %~fs0 :","","runas",0)(window.close) && exit set /a Col=64,Row=30 for /f "tokens=1,2 delims= " %%a in ( 'mshta VBScript:Execute("CreateObject(""Scripting.Filesystemobject"").GetStandardStream(1).Write(screen.width&"" ""&screen.height)"^)(window.close^)' ) do ( set ScrW=%%a set ScrH=%%b ) set F=0123456789ABCDEF set /a WinW=Col*8+20,WinH=Row*16+44,PosL=(ScrW-WinW)/2,PosT=(ScrH-WinH)/2,"PosD=PosT<<16|PosL" :D2H set /a mod = %PosD% %% 16,PosD /=16 set en=%mod% %en% if not %PosD% lss 1 (goto D2H) & set PosH= for %%i in (%en%) do (call set PosH=!PosH!%%F:~%%i,1%%) (for %%a in ( CodePage:000003a8 QuickEdit:00000000 InsertMode:00000000 CursorSize:00000019 FontFamily:00000000 FontWeight:00000000 FontSize:00100008 WindowSize:001e0040 WindowPosition:%PosH% ColorTable00:00000000 ScreenBufferSize:001e0040 ) do ( for /f "tokens=1,2 delims=:" %%b in ("%%a") do ( >nul reg add HKCU\Console\SanGod /v %%b /t REG_DWORD /d 0x%%c /f ) ) reg add HKCU\Console\SanGod /v FaceName /d Terminal /f reg query HKEY_CURRENT_USER\Console /v ForceV2 && for /f "tokens=3" %%a in ( 'reg query HKEY_CURRENT_USER\Console /v ForceV2' ) do ( set V2=%%a reg add HKEY_CURRENT_USER\Console /v ForceV2 /t REG_DWORD /d 0x00000000 /f ) ping -n 1 127.1)>nul 2>nul start /i "SanGod" "%~dps0Tools\cmd.exe" /c %~fs0 : %Col% %Row% (ping -n 2 127.1 if not "%V2%"=="" reg add HKEY_CURRENT_USER\Console /v ForceV2 /t REG_DWORD /d %V2% /f reg delete HKCU\Console\SanGod /f exit)>nul :RegEnd setlocal enabledelayedexpansion fltmc>nul||echo Not admin rights set CAPI=CAPIDll Ver if "%CAPI_Ret%"=="" ( echo Cmd hook failed ENDLOCAL goto RegEnd ) set CAPI=Mem Alloc 8 set lpCCI=!CAPI_Ret! set CAPI=Mem Put ;!lpCCI! ;100 set CAPI=API Call kernel32 GetStdHandle ;-11 set hOut=!CAPI_Ret! set CAPI=API Call kernel32 SetConsoleCursorInfo ;!hOut! ;!lpCCI! set CAPI=Mem Free !lpCCI! set CAPI=API Call user32 LoadImageW ;0 $Graphics\desktop.ico ;1 ;0 ;0 ;16 set hIco_cmd=!CAPI_Ret! set CAPI=API Call kernel32 SetConsoleIcon ;!hIco_cmd!" set CAPI=API Call kernel32 GetConsoleWindow set hCMD=!CAPI_Ret! set CAPI=Mem Alloc 16 set lpRC=!CAPI_Ret! set CAPI=API Call user32 GetWindowRect ;!hCMD! ;!lpRC! set CAPI=Mem Print ;!lpRC! ;xLeft ;yTop ;xRight ;yBottom set /a xWidth=xRight-xLeft,yHeight=yBottom-yTop set CAPI=API Call user32 ScreenToClient ;!hCMD! ;!lpRC! set CAPI=Mem Print ;!lpRC! ;xWnd ;yWnd set /a xWnd=-xWnd,yWnd=-yWnd set CAPI=API Call user32 GetDesktopWindow set CAPI=API Call user32 GetClientRect ;!CAPI_Ret! ;!lpRC! set CAPI=Mem Print ;!lpRC! @8 ;xScreen ;yScreen set /a xPos=xScreen-xWidth,xPos/=2,yPos=yScreen-yHeight,yPos/=2 set CAPI=API Call user32 MoveWindow ;!hCMD! ;!xPos! ;!yPos! ;!xWidth! ;!yHeight! ;1 set CAPI=Mem Free !lpRC!" set CAPI=API Call kernel32 ConsoleMenuControl ;!hOut! ;501 ;503 set hMenu=!CAPI_Ret! set CAPI=API Call user32 GetMenuItemCount ;!hMenu! for /l %%a in (!CAPI_Ret!,-1,0) do ( set CAPI=API Call user32 GetMenuItemID ;!hMenu! ;%%a if "!CAPI_Ret!" neq "61536" set CAPI=API Call user32 DeleteMenu ;!hMenu! ;%%a ;1024 ) ENDLOCAL :InitEnd setlocal enabledelayedexpansion rem 以上为初始化运行环境 http://blog.snote.cn/batheader/ |
参照评论区旧版,添加一项功能:防止重复运行!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
@echo off & setlocal enabledelayedexpansion (mode con cols=%Col% lines=%Row% cd /d "%~dp0" & chcp 936)>nul if not "%1"=="" ( %2 %0 ZhangZsky : 3>>%0||exit goto InitEnd) echo,Init… & set /a Col=64,Row=30 for /f "tokens=4 delims=. " %%a in ('ver') do (if %%a==10 ( for /f "tokens=3" %%b in ('reg query HKEY_CURRENT_USER\Console^|findstr ForceV2') do (set V2=%%b) >nul reg add HKEY_CURRENT_USER\Console /v ForceV2 /t REG_DWORD /d 0x00000000 /f)) echo,var screen = new ActiveXObject("HTMLFile").parentWindow.screen;+WScript.Echo(screen.width + ' ' + screen.height);>%temp%\Js.t for /f "tokens=1,2 delims= " %%a in ('cscript //nologo //e:jscript %temp%\Js.t') do (set ScrW=%%a& set ScrH=%%b) & del %temp%\Js.t set /a WinW=Col*8+20,WinH=Row*16+33,PosL=(ScrW-WinW)/2,PosT=(ScrH-WinH)/2,"PosD=PosT<<16|PosL" set F=0123456789ABCDEF :D2H set /a mod = %PosD% %% 16,PosD /=16 set en=%mod% %en% if not %PosD% lss 1 (goto D2H) & set PosH= for %%i in (%en%) do (call set PosH=!PosH!%%F:~%%i,1%%) for %%a in ( CodePage:000001b5 QuickEdit:00000000 CursorSize:00000019 FontFamily:00000030 FontSize:00100008 ColorTable00:00000000 WindowPosition:%PosH% ) do (for /f "tokens=1,2 delims=:" %%b in ("%%a") do (>nul reg add HKCU\Console\SanGod /v %%b /t REG_DWORD /d 0x%%c /f)) (echo,Option Explicit & echo,Dim wshShell, Shortcut & echo,Dim strDir, strName echo,strName = "SanGod" & echo,Set wshShell = WSH.CreateObject^("WScript.Shell"^) & echo,strDir = "%cd%" echo, Set Shortcut = wshShell.CreateShortcut^(strDir ^&_ & echo, "\" ^& strName ^& ".lnk"^) echo, Shortcut.TargetPath = "%ComSpec%" echo, Shortcut.IconLocation = "%cd%\Graphics\desktop.ico" echo, Shortcut.WindowStyle = 1 echo, Shortcut.WorkingDirectory = strDir echo, Shortcut.Save)>%temp%\Stc.vbs & start /w %temp%\Stc.vbs & del %temp%\Stc.vbs start "SanGod" "SanGod.lnk" /c "%~s0" : (if not "%V2%"=="" echo,yes|reg add HKEY_CURRENT_USER\Console /v ForceV2 /t REG_DWORD /d %V2% reg delete HKCU\Console\SanGod /f)>nul & del SanGod.lnk & exit :InitEnd |
发表回复