I am trying to start psexec in a hidden window but can't seem to get it right. When I run the script (actually a HTML Application) I get Error: Object doesn't support this property or method. The line number matches the line where I'm trying to set the property. If I set it to "null" no error and the script works but the window is not hidden. var strComputer = "."; var strCommand = "psexec \\\\rmtserver cmd.exe /k"; var objWMIService = GetObject("winmgmts:\\\\" + strComputer + "\\root\\CIMV2"); var objProcess = objWMIService.Get("Win32_Process"); var objInParam = objProcess.Methods_("Create").inParameters.SpawnInstance_(); var objStartup = objWMIService.Get("Win32_ProcessStartup").SpawnInstance_(); objStartup.ShowWindow = 0; objInParam.Properties_.Item("CommandLine") = strCommand; objInParam.Properties_.Item("ProcessStartupInformation") = objStartup; try { var objOutParams = objWMIService.ExecMethod( "Win32_Process", "Create", objInParam ); if ( objOutParams.ReturnValue == 0 ) { g_intProcessID = objOutParams.ProcessId; alert( "intProcessID: " + g_intProcessID ); } } catch ( e ) { var msgText = "RemoteAccess.hta:\n"; if ( typeof( e.num) != "undefined" ) { msgText = e.num + "\n"; } msgText += e.description; alert( msgText ); }
"TxDot" wrote: > I am trying to start psexec in a hidden window but can't seem to get it > right. When I run the script (actually a HTML Application) I get Error: > Object doesn't support this property or method. The line number matches the > line where I'm trying to set the property. If I set it to "null" no error and > the script works but the window is not hidden. > > var strComputer = "."; > var strCommand = "psexec \\\\rmtserver cmd.exe /k"; > > var objWMIService = GetObject("winmgmts:\\\\" + strComputer + > "\\root\\CIMV2"); > var objProcess = objWMIService.Get("Win32_Process"); > var objInParam = > objProcess.Methods_("Create").inParameters.SpawnInstance_(); > var objStartup = > objWMIService.Get("Win32_ProcessStartup").SpawnInstance_(); > objStartup.ShowWindow = 0; > > objInParam.Properties_.Item("CommandLine") = strCommand; > objInParam.Properties_.Item("ProcessStartupInformation") = objStartup; > > try > { > var objOutParams = objWMIService.ExecMethod( "Win32_Process", > "Create", objInParam ); > > if ( objOutParams.ReturnValue == 0 ) > { > g_intProcessID = objOutParams.ProcessId; > alert( "intProcessID: " + g_intProcessID ); > } > } > catch ( e ) > { > var msgText = "RemoteAccess.hta:\n"; > > if ( typeof( e.num) != "undefined" ) > { > msgText = e.num + "\n"; > } > > msgText += e.description; > > alert( msgText ); > } > Try: objInParam.Properties_.Item("CommandLine").Value = strCommand; objInParam.Properties_.Item("ProcessStartupInformation").Value = objStartup; -- urkec
"urkec" wrote: > "TxDot" wrote: > > > I am trying to start psexec in a hidden window but can't seem to get it > > right. When I run the script (actually a HTML Application) I get Error: > > Object doesn't support this property or method. The line number matches the > > line where I'm trying to set the property. If I set it to "null" no error and > > the script works but the window is not hidden. > > > > var strComputer = "."; > > var strCommand = "psexec \\\\rmtserver cmd.exe /k"; > > > > var objWMIService = GetObject("winmgmts:\\\\" + strComputer + > > "\\root\\CIMV2"); > > var objProcess = objWMIService.Get("Win32_Process"); > > var objInParam = > > objProcess.Methods_("Create").inParameters.SpawnInstance_(); > > var objStartup = > > objWMIService.Get("Win32_ProcessStartup").SpawnInstance_(); > > objStartup.ShowWindow = 0; > > > > objInParam.Properties_.Item("CommandLine") = strCommand; > > objInParam.Properties_.Item("ProcessStartupInformation") = objStartup; > > > > try > > { > > var objOutParams = objWMIService.ExecMethod( "Win32_Process", > > "Create", objInParam ); > > > > if ( objOutParams.ReturnValue == 0 ) > > { > > g_intProcessID = objOutParams.ProcessId; > > alert( "intProcessID: " + g_intProcessID ); > > } > > } > > catch ( e ) > > { > > var msgText = "RemoteAccess.hta:\n"; > > > > if ( typeof( e.num) != "undefined" ) > > { > > msgText = e.num + "\n"; > > } > > > > msgText += e.description; > > > > alert( msgText ); > > } > > > > Try: > > > objInParam.Properties_.Item("CommandLine").Value = strCommand; > objInParam.Properties_.Item("ProcessStartupInformation").Value = objStartup; > > -- > urkec Thanks urkec. That worked. I guess since the CommandLine parm is a string specifying Value isn't needed but since ProcessStartupInformation is an object of type Win32_ProcessStartup it has to have Value specified. It would sure be nice if the examples and documentation on MSDN more clearly depicted this. Thanks again...