Advertisement
Guest User

Create Notepad process

a guest
Mar 14th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim objWMIService
  2. Dim objStartup
  3. Dim objConfig
  4. Dim objProcess
  5. Const SW_NORMAL = 1
  6. strComputer = "."
  7. strCommand = "Notepad.exe"
  8. Set objWMIService = GetObject("winmgmts:" _
  9.     & "{impersonationLevel=impersonate}!\\" _
  10.     & strComputer & "\root\cimv2")
  11.  
  12. ' Configure the Notepad process to show a window
  13. Set objStartup = objWMIService.Get("Win32_ProcessStartup")
  14. Set objConfig = objStartup.SpawnInstance_
  15. objConfig.ShowWindow = SW_NORMAL
  16.  
  17. ' Create Notepad process
  18. Set objProcess = objWMIService.Get("Win32_Process")
  19. intReturn = objProcess.Create _
  20.     (strCommand, Null, objConfig, intProcessID)
  21. If intReturn <> 0 Then
  22.     Wscript.Echo "Process could not be created." & _
  23.         vbNewLine & "Command line: " & strCommand & _
  24.         vbNewLine & "Return value: " & intReturn
  25. Else
  26.     Wscript.Echo "Process created." & _
  27.         vbNewLine & "Command line: " & strCommand & _
  28.         vbNewLine & "Process ID: " & intProcessID
  29. End If
  30.  
  31. Set objWMIService = Nothing
  32. Set objStartup = Nothing
  33. Set objConfig = Nothing
  34. Set objProcess = nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement