I've done a fair amount of searching about for a solution and have not found anything that work specifically for EXPLORER.EXE.
What I want to do is:
1. On the local machine run a new instance of explorer.exe, hidden
2. Capture the PID info for later use
I have a couple of scripts that get me close, but not being a scripting guy I cannot figure out how to make either of them work 100%.
Any input, thoughts, ideas, etc., would be greatly appreciated.
Script 1 - Runs explorer.exe hidden, but I cannot figure out how to get the PID info.
'--------- Start -----------
Set oShell = wScript.CreateObject("wScript.Shell")
oShell.Run("C:\Windows\explorer.exe"), 0, False
'---------- End ----------
Script 2 - Runs other apps hidden, and reports the PID. But does not hide Explorer.
'--------- Start -----------
Const strComputer = "."
Const HIDDEN_WINDOW = 0
Const MyInitialProcess = "c:\windows\system32\notepad.exe"
Const MyApp = "calc.exe"
Set objShell = Wscript.CreateObject("Wscript.Shell")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & strComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = HIDDEN_WINDOW
Set objProcess = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
objProcess.Create MyInitialProcess, null, objConfig, initialPID
If errReturn = 0 Then
WScript.Echo "Process ID is: " & initialPID
End If
'---------- End ------------
What I want to do is:
1. On the local machine run a new instance of explorer.exe, hidden
2. Capture the PID info for later use
I have a couple of scripts that get me close, but not being a scripting guy I cannot figure out how to make either of them work 100%.
Any input, thoughts, ideas, etc., would be greatly appreciated.
Script 1 - Runs explorer.exe hidden, but I cannot figure out how to get the PID info.
'--------- Start -----------
Set oShell = wScript.CreateObject("wScript.Shell")
oShell.Run("C:\Windows\explorer.exe"), 0, False
'---------- End ----------
Script 2 - Runs other apps hidden, and reports the PID. But does not hide Explorer.
'--------- Start -----------
Const strComputer = "."
Const HIDDEN_WINDOW = 0
Const MyInitialProcess = "c:\windows\system32\notepad.exe"
Const MyApp = "calc.exe"
Set objShell = Wscript.CreateObject("Wscript.Shell")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Security)}!\\" & strComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = HIDDEN_WINDOW
Set objProcess = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
objProcess.Create MyInitialProcess, null, objConfig, initialPID
If errReturn = 0 Then
WScript.Echo "Process ID is: " & initialPID
End If
'---------- End ------------