3 Replies - 2731 Views - Last Post: 10 October 2012 - 08:58 AM Rate Topic: -----

#1 harishkothuri  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 10-October 12

Launching process in remote machine

Posted 10 October 2012 - 07:55 AM

I'm trying to launch notepad in remote machine using WMI module. But i'm getting error telling " process Not Found "

Something is going wrong with my code here.. :(

object[] theProcessToRun = { "notepad.exe" };
System.Management.ConnectionOptions theConnection = new System.Management.ConnectionOptions();
theConnection.Username = "username";
theConnection.Password = "password";
ManagementScope scope = new ManagementScope("\\\\Machinename\\root\\cimv2", theConnection);
scope.Connect();
ManagementClass theClass = new ManagementClass(scope, new ManagementPath("Notepad"), new ObjectGetOptions());
theClass.InvokeMethod("Create", theProcessToRun);


Detailed error message is as below.

System.Management.ManagementException was unhandled by user code
Message=Not found
Source=System.Management
StackTrace:
at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode)
at System.Management.ManagementObject.Initialize(Boolean getObject)
at System.Management.ManagementObject.get_ClassPath()
at System.Management.ManagementObject.GetMethodParameters(String methodName, ManagementBaseObject& inParameters, IWbemClassObjectFreeThreaded& inParametersClass, IWbemClassObjectFreeThreaded& outParametersClass)
at System.Management.ManagementObject.InvokeMethod(String methodName, Object[] args)
at _Default.btnRemote_Click(Object sender, EventArgs e) in c:\Documents and Settings\USER\My Documents\Visual Studio 2010\WebSites\WMI_CS\Default.aspx.cs:line 31
at System.Web.UI.WebControls.Button.onclick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:


I hope someone will help me in this regard.

Thanks,
Harish


Is This A Good Question/Topic? 0
  • +

Replies To: Launching process in remote machine

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3643
  • View blog
  • Posts: 11,410
  • Joined: 05-May 12

Re: Launching process in remote machine

Posted 10 October 2012 - 08:25 AM

I avoid WMI as much as I avoid SIDs and ACLs, but do you have the correct parameter to the ManagementPath constructor? Shouldn't it be something like "Win32_Process" or something like that?
Was This Post Helpful? 0
  • +
  • -

#3 harishkothuri  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 10-October 12

Re: Launching process in remote machine

Posted 10 October 2012 - 08:32 AM

View PostSkydiver, on 10 October 2012 - 08:25 AM, said:

I avoid WMI as much as I avoid SIDs and ACLs, but do you have the correct parameter to the ManagementPath constructor? Shouldn't it be something like "Win32_Process" or something like that?


Thanks a lot.. it was working now in the background process [ i am able to see it in process ].
How do i bring it normally ?
Also, can you tell me how to start running the own process ( not system processes )

Thanks,
Harish
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3643
  • View blog
  • Posts: 11,410
  • Joined: 05-May 12

Re: Launching process in remote machine

Posted 10 October 2012 - 08:58 AM

Quote

You can use Win32_Process.Create to execute a script or application on a remote computer. However, for security reasons, the process cannot be interactive. When Win32_Process.Create is called on the local computer, the process can be interactive.


http://msdn.microsof...9(v=vs.85).aspx

Why do you need to launch an interactive application on a remote machine? What if there is nobody there to interact with it? What if it is a headless (no monitor, mouse, or keyboard) machine?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1