views:

571

answers:

1

Hi

I am trying to launch .appref-ms (Click once) application on remote machine using WMI but could not get success. The below code works fine if i try to run notpad.exe

ManagementPath pm = new ManagementPath(@"\server\root\cimv2:Win32_process"); ManagementClass processClass = new ManagementClass(pm);

        //Get an input parameters object for this method
        ManagementBaseObject inParams = processClass.GetMethodParameters("Create");

        //Fill in input parameter values
        inParams["CommandLine"] = @"C:\Documents and Settings\Start Menu\Programs\New\New App.appref-ms";

        //Execute the method
        ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);
A: 

What is the error that you are getting.

BTW, there seem to be two problems with the commandline path that you are using.

  1. Start Menu folder IMO is in C:\Documents and Settings\"Usernamehere"\StartMenu.
  2. I am not sure but I think that you can't run a program remotely which lies inside a user's profile. Try installing the program to some other location like your c:\program files and then try to call it.

Apart from that, if you mention the exact error you are getting, then it would be helpful to diagnose the problem.

Aamir
Hi AmirFor point 1 there is username i just removed it from the code. Now i have put the New App.appref-ms in C: dive but still not able to launch it. I get the error code "8" which means "Unknown failure" using the below codeManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);Console.WriteLine("process returned: " + outParams["returnValue"]);
Raj Kumar