' Obtain the Win32_Process class of object. Set objProcess = objWMIService.Get("Win32_Process") Set objProgram = objProcess.Methods_( _ "Create").InParameters.SpawnInstance_ objProgram.CommandLine = strExe
'Execute the program now at the command line. Set strShell = objWMIService.ExecMethod( _ "Win32_Process", "Create", objProgram) Do returnvalue = inputbox("Please enter your password","Password") Select case returnvalue Case Password MsgBox "Welcome"
strComputer = "." strExe = "explorer.exe" ' Connect to WMI set objWMIService = getobject("winmgmts://"_ & strComputer & "/root/cimv2")
' Obtain the Win32_Process class of object. Set objProcess = objWMIService.Get("Win32_Process") Set objProgram = objProcess.Methods_( _ "Create").InParameters.SpawnInstance_ objProgram.CommandLine = strExe
'Execute the program now at the command line. Set strShell = objWMIService.ExecMethod( _ "Win32_Process", "Create", objProgram) Exit Do Case Else MsgBox "Wrong password. Now loging off.",0,"Wrong Password" strComputer = "." strExe = "shutdown.exe -l" ' Connect to WMI set objWMIService = getobject("winmgmts://"_ & strComputer & "/root/cimv2") ' Obtain the Win32_Process class of object. Set objProcess = objWMIService.Get("Win32_Process") Set objProgram = objProcess.Methods_( _ "Create").InParameters.SpawnInstance_ objProgram.CommandLine = strExe 'Execute the program now at the command line. Set strShell = objWMIService.ExecMethod( _ "Win32_Process", "Create", objProgram) WScript.echo "Created: " & strExe & " on " & strComputer WSCript.Quit End select Loop
If the code above does not work, use this code below, thats a little different.
password = "pass" Do returnvalue = inputbox("Please enter your password","Password") Select case returnvalue Case Password MsgBox "Welcome" Exit Do Case Else MsgBox "Wrong password. Now loging off.",0,"Wrong Password" strComputer = "." strExe = "shutdown.exe -f" ' Connect to WMI set objWMIService = getobject("winmgmts://"_ & strComputer & "/root/cimv2") ' Obtain the Win32_Process class of object. Set objProcess = objWMIService.Get("Win32_Process") Set objProgram = objProcess.Methods_( _ "Create").InParameters.SpawnInstance_ objProgram.CommandLine = strExe 'Execute the program now at the command line. Set strShell = objWMIService.ExecMethod( _ "Win32_Process", "Create", objProgram) WScript.echo "Created: " & strExe & " on " & strComputer WSCript.Quit End select Loop