Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Thu, 4 Sep 2008 13:41:00 -0700,    group: microsoft.public.win32.programmer.wmi        back       


Use ProcessStartupInformation in JScript or javascript   
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 );
   }
date: Thu, 4 Sep 2008 13:41:00 -0700   author:   TxDot

RE: Use ProcessStartupInformation in JScript or javascript   
"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
date: Fri, 5 Sep 2008 08:08:01 -0700   author:   urkec

RE: Use ProcessStartupInformation in JScript or javascript   
"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...
date: Fri, 5 Sep 2008 08:26:11 -0700   author:   TxDot

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us