c# - To open an EXE on a remote computer using ip address -
i want open program on remote computer ip 10.64.4.38 through c# windows based program.
the file want open on . @"c:\program files\realvnc\vnc viewer\vncviewer.exe"
i using following code it's not working. please me out
connectionoptions options = new connectionoptions(); options.impersonation = impersonationlevel.impersonate; options.authentication = authenticationlevel.default; options.username = username; options.password = password; options.authority = null; options.enableprivileges = true; managementscope scope = new managementscope(path, options); scope.connect(); // create process using (managementclass process = new managementclass("win32_process")) { connectionoptions conn = new connectionoptions(); conn.username = "support"; conn.password = "password"; process.scope = scope; process.invokemethod("create", commandline); managementscope ms = new managementscope(@"\\10.64.4.38\root\cimv2", conn); process g = process.start(@"c:\\program files\realvnc\vnc viewer\vncviewer.exe");
this excerpt program wrote you're trying do. used process g = .. creates local process. not wanted.
connectionoptions connoptions = new connectionoptions(); connoptions.impersonation = impersonationlevel.impersonate; connoptions.enableprivileges = true; managementscope manscope = new managementscope(string.format(@"\\{0}\root\cimv2", remotemachine), connoptions); manscope.connect(); objectgetoptions objectgetoptions = new objectgetoptions(); managementpath managementpath = new managementpath("win32_process"); managementclass processclass = new managementclass(manscope, managementpath, objectgetoptions); managementbaseobject inparams = processclass.getmethodparameters("create"); console.writeline("{0}>remoteexec: {1}",remotemachine, sbatfile); inparams["commandline"] = sbatfile; inparams["currentdirectory"] = !nocopy?@"c:\656":@"c:\"; // part of current process needs remote folder wish work from, c:\656 default managementbaseobject outparams = processclass.invokemethod("create", inparams, null); uint32 rv = (uint32) outparams["returnvalue"]; uint processid = (uint) outparams["processid"]; string result = ""; switch (rv) { case 0: result = "ok"; break; case 2: result = "access denied"; break; case 3: result = "insufficient privilage"; break; case 8: result = "unknown failure"; break; case 9: result = "path not found"; break; case 21: result = "unknown failure"; break; default: result = "mega bad"; break; } console.writeline("{0}>creation of process returned: {1}",remotemachine,result);
this tell why remote process failed.. if fails launch
Comments
Post a Comment