需要在用户不可见的批处理脚本中进行命令(Need to make command in batch script invisible to user)

编程入门 行业动态 更新时间:2024-10-28 17:23:58
需要在用户不可见的批处理脚本中进行命令(Need to make command in batch script invisible to user)

我需要帮助使GPupdate /force完全对用户不可见。

我以前看过这个。 目前,它回答了一个问题,不会自动将用户从PC上注销,但我希望可以在视觉上关闭该批次,但在后台完成gpupdate。

@echo off Title Internet Explorer Full Reset ::Close Internet Explorer tasks taskkill.exe /f /im iexplore.exe ::Wait timeout /t 4 ::Performs reset on all settings for Internet Explorer reg delete "HKCU\Software\Microsoft\Internet Explorer" /f ::Wait timeout /t 2 ::Clear all temporary internet files RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 ::Clear all cookies RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 ::Clear all form data RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16 ::Wait timeout /t 1 :: Set IE to always check for new versions of pages automatically ::reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /V SyncMode5 /t REG_DWORD /d 3 /f ::Wait timeout /t 1 ::Enable favorites bar in Internet Explorer REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MINIE" /V "LinksBandEnabled" /D "00000001" /F ::Enable menu bar in Internet Explorer REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MINIE" /V "AlwaysShowMenus" /D "00000001" /F ::Enable command bar in Internet Explorer REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MINIE" /V "CommandBarEnabled" /D "00000001" /F ::Enable status bar in Internet Explorer REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MINIE" /V "ShowStatusBar" /D "00000001" /F ::Relaunch Internet Explorer start iexplore.exe ::Update Group Policy to bring all Internet Explorer settings back into compliance echo N | gpupdate /force ::Schedule task to reboot at 11:59PM ::schtasks /create /sc once /tn restart /tr "shutdown -r -f ""restart""" /st 23:59 ::Message To User msg * "Please restart your computer to complete configuration changes when you are next able."

I need help making GPupdate /force fully invisible to the user.

I've seen this in the past. Currently it answers a question to not log the user off the PC automatically but I would like to have the batch close visually but finish the gpupdate in the background.

@echo off Title Internet Explorer Full Reset ::Close Internet Explorer tasks taskkill.exe /f /im iexplore.exe ::Wait timeout /t 4 ::Performs reset on all settings for Internet Explorer reg delete "HKCU\Software\Microsoft\Internet Explorer" /f ::Wait timeout /t 2 ::Clear all temporary internet files RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 ::Clear all cookies RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 ::Clear all form data RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16 ::Wait timeout /t 1 :: Set IE to always check for new versions of pages automatically ::reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /V SyncMode5 /t REG_DWORD /d 3 /f ::Wait timeout /t 1 ::Enable favorites bar in Internet Explorer REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MINIE" /V "LinksBandEnabled" /D "00000001" /F ::Enable menu bar in Internet Explorer REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MINIE" /V "AlwaysShowMenus" /D "00000001" /F ::Enable command bar in Internet Explorer REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MINIE" /V "CommandBarEnabled" /D "00000001" /F ::Enable status bar in Internet Explorer REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MINIE" /V "ShowStatusBar" /D "00000001" /F ::Relaunch Internet Explorer start iexplore.exe ::Update Group Policy to bring all Internet Explorer settings back into compliance echo N | gpupdate /force ::Schedule task to reboot at 11:59PM ::schtasks /create /sc once /tn restart /tr "shutdown -r -f ""restart""" /st 23:59 ::Message To User msg * "Please restart your computer to complete configuration changes when you are next able."

最满意答案

我为这种情况使用了一个简单的VBScript。 使用命令start "" "directory\update.vbs" 。 VBScript(名为update.vbs)的内容如下所示:

Const HIDDEN_WINDOW = 12 strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objStartup = objWMIService.Get("Win32_ProcessStartup") Set objConfig = objStartup.SpawnInstance_ objConfig.ShowWindow = HIDDEN_WINDOW Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process") errReturn = objProcess.Create("DIRECTORY\update.bat", null, objConfig, intProcessID)

请注意,您必须将DIRECTORY\update.bat替换为批处理文件的文件目录和名称。 这应该完全静默运行(用户没有看到一件事)。

I use a simple VBScript for cases like this. Use the command start "" "directory\update.vbs". The contents of the VBScript (named update.vbs) are as follows:

Const HIDDEN_WINDOW = 12 strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set objStartup = objWMIService.Get("Win32_ProcessStartup") Set objConfig = objStartup.SpawnInstance_ objConfig.ShowWindow = HIDDEN_WINDOW Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process") errReturn = objProcess.Create("DIRECTORY\update.bat", null, objConfig, intProcessID)

Please note that you will have to replace DIRECTORY\update.bat with the file directory and name of your batch file. This should run it completely silently (user doesn't see a thing).

更多推荐

本文发布于:2023-07-14 23:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1108390.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:批处理   脚本   命令   用户   command

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!