Create A Process in A Hidden Window Script

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Create a Process in a Hidden Window

Description
Starts Notepad.exe on the local computer, but in a hidden window.
Script Code
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("Notepad.exe", null, objConfig, intProcessID)

For online peer support, join the microsoft.public.windows.server.scripting comm


unity on the msnews.microsoft.com news server. To provide feedback or report bug
s in sample scripts or the Scripting Guide, please contact Microsoft TechNet.
Disclaimer
The sample scripts are not supported under any Microsoft standard support progra
m or service. The sample scripts are provided AS IS without warranty of any kind
. Microsoft further disclaims all implied warranties including, without limitati
on, any implied warranties of merchantability or of fitness for a particular pur
pose. The entire risk arising out of the use or performance of the sample script
s and documentation remains with you. In no event shall Microsoft, its authors,
or anyone else involved in the creation, production, or delivery of the scripts
be liable for any damages whatsoever (including, without limitation, damages for
loss of business profits, business interruption, loss of business information,
or other pecuniary loss) arising out of the use of or inability to use the sampl
e scripts or documentation, even if Microsoft has been advised of the possibilit
y of such damages.

You might also like