I need a vbs script that will run through a scheduled task. The vbs script will be used to disable windows update scheduled tasks, which require special privileges, using Psexec. Psexec.exe is located in the same directory as the vbs script. Trying to do it through vbscript hoping Psexec.exe console would not be visible. I Can do it by using cmd script, but can not hide Psexec.exe console window, which I don't want to be visible as I don't want users/anyone to see something is launched. The console shows briefly and quits, but it is still visible.
%~dp0psexec.exe -i -d -s -accepteula schtasks /change /tn "Microsoft\Windows\WindowsUpdate\sihpostreboot" /disable
I tried but could not make Psexec disable the task through vbs script at all, with the console window visible or not.
Option Explicit
Dim fso
Dim GetTheParent
Dim vbhide
Set fso = CreateObject("Scripting.FileSystemObject")
GetTheParent = fso.GetParentFolderName(Wscript.ScriptFullName)
Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run GetTheParent & "\psexec.exe -i -d -s -accepteula schtasks /change /tn \Microsoft\Windows\WindowsUpdate\sihpostreboot /disable", vbhide