windows_10_2008r2_2016server_开机startup_关机shutdown_分别执行bat脚本
转载注明来源: 本文链接 来自osnosn的博客,写于 2021-06-16.
参考
- 【Win10系统设置在开机,关机,登录时执行脚本】,用(gpedit.msc)本地组策略编辑器.
- 【win10关机时执行bat脚本】,用gpedit.msc
- 【Executing a batch script on Windows shutdown】,用注册表导入。win10专业版测试ok.
- 【Executing a batch script on Windows shutdown】,用注册表导入。此文说在2008r2和2016server上测试成功。
- 【Windows: Execute a Script at shutdown】,用注册表导入。win10专业版测试ok.
- 【Register Windows Startup/Shutdown script】
win10 开机、关机时,执行脚本
- 因 gpedit 被禁用,没有权限。所以用注册表导入的方法指定开关机执行的脚本,win10专业版17763测试成功。(2021-06)
- 相关的注册表内容。开机:
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyScriptsStartup
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScriptsStartup
HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionGroup PolicyScriptsStartup
HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScriptsStartup
字符串keyScript=C:xxxxxxx.bat
- 相关的注册表内容。关机:
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyScriptsShutdown
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScriptsShutdown
HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionGroup PolicyScriptsShutdown
HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScriptsShutdown
字符串keyScript=C:xxxxxxx.bat
- 开机
reg-startup.reg
:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScripts]
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScriptsStartup]
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyScriptsStartup]
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScriptsStartup ]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\Windows\System32\GroupPolicy\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScriptsStartup ]
"Script"="C:\Scripts\startupEv.bat"
"Parameters"=""
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyScriptsStartup ]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\Windows\System32\GroupPolicy\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyScriptsStartup ]
"Script"="C:\Scripts\startupEv.bat"
"Parameters"=""
"IsPowershell"=dword:00000000
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
- 关机
reg-shutdown.reg
:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScripts]
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScriptsShutdown]
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyScriptsShutdown]
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScriptsShutdown ]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\Windows\System32\GroupPolicy\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyStateMachineScriptsShutdown ]
"Script"="C:\Scripts\shutdownEv.bat"
"Parameters"=""
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyScriptsShutdown ]
"GPO-ID"="LocalGPO"
"SOM-ID"="Local"
"FileSysPath"="C:\Windows\System32\GroupPolicy\Machine"
"DisplayName"="Local Group Policy"
"GPOName"="Local Group Policy"
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyScriptsShutdown ]
"Script"="C:\Scripts\shutdownEv.bat"
"Parameters"=""
"IsPowershell"=dword:00000000
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
- 按需,分别双击
reg-startup.reg
,reg-shutdown.reg
导入到注册表即可。