- @echo off
- set script=c:\test\a.bat
- set arg=
-
- set script=%script:\=\\%
- if not "%arg%"=="" set arg=%arg:\=\\%
- attrib -h -r -s C:\WINDOWS\System32\GroupPolicy\User\Scripts\scripts.ini 2>nul 1>nul
-
- (
- echo.
- echo [Logoff]
- echo 0CmdLine=%script%
- echo 0Parameters=%arg%
- )>C:\WINDOWS\System32\GroupPolicy\User\Scripts\scripts.ini
-
- attrib +h C:\WINDOWS\System32\GroupPolicy\User\Scripts\scripts.ini
-
- (
- echo Windows Registry Editor Version 5.00
- echo.
- echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0]
- echo "GPO-ID"="LocalGPO"
- echo "SOM-ID"="Local"
- echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User"
- echo "DisplayName"="Local Group Policy"
- echo "GPOName"="Local Group Policy"
- echo.
- echo [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff\0\0]
- echo "Script"="%script%"
- echo "Parameters"="%arg%"
- echo "ExecTime"=hex^(b^):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
- echo.
- echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\S-1-5-21-515967899-839522115-1343024091-500\Scripts\Logoff\0]
- echo "GPO-ID"="LocalGPO"
- echo "SOM-ID"="Local"
- echo "FileSysPath"="C:\\WINDOWS\\System32\\GroupPolicy\\User"
- echo "DisplayName"="Local Group Policy"
- echo "GPOName"="Local Group Policy"
- echo.
- echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\S-1-5-21-515967899-839522115-1343024091-500\Scripts\Logoff\0\0]
- echo "Script"="%script%"
- echo "Parameters"="%arg%"
- echo "ExecTime"=hex^(b^):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
- )>Logoff.reg
- regedit /s Logoff.reg
- del Logoff.reg
复制代码 这个脚本执行后,还要到组策略注销脚本里点确定才能生效,看看能不能怎么修改。 |