需要使批处理脚本中的命令对用户不可见

时间:2017-03-02 15:00:44

标签: batch-file cmd

我需要帮助使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."

1 个答案:

答案 0 :(得分:0)

我使用简单的VBScript来处理这样的情况。使用命令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) 。 VBScript(名为update.vbs)的内容如下:

DIRECTORY\update.bat

请注意,您必须将import org.opencv.core.Core; import org.opencv.core.CvType; import org.opencv.core.Mat; public class Hello { public static void main( String[] args ) { System.loadLibrary( Core.NATIVE_LIBRARY_NAME ); Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 ); System.out.println( "mat = " + mat.dump() ); } } 替换为批处理文件的文件目录和名称。这应该完全静默运行(用户看不到任何东西)。