Hi all
I would like to execute a file (.exe, .cmd, .bat etc.) on a remote
machine (File is stored on the remote machine) ...
Does anybody know how to do this
Do I have to use WMI If yes, how
Thanks for any comments !!
Best regards
Frank Uray
Hi all
I would like to execute a file (.exe, .cmd, .bat etc.) on a remote
machine (File is stored on the remote machine) ...
Does anybody know how to do this
Do I have to use WMI If yes, how
Thanks for any comments !!
Best regards
Frank Uray
Execute file on remote machine (WMI ??) ...
Aeraf
... it has to be something like this ...
but I dont know where to put the path and the executable name etc.
System.Management.
ConnectionOptions connection = new System.Management.ConnectionOptions();connection.Username = "MyUser";
connection.Password = "MyPasswort";
connection.Authority = "ntlmdomain:MyDomain";
System.Management.
ManagementScope scope = new System.Management.ManagementScope("\\\\MyServer\\root\\CIMV2", connection);scope.Connect();
System.Management.
ManagementClass classInstance = new System.Management.ManagementClass(scope, new ManagementPath("Win32_Process"), null); // Obtain in-parameters for the methodSystem.Management.
ManagementBaseObject inParams = classInstance.GetMethodParameters("Create"); // Add the input parameters. // Execute the method and obtain the return values.System.Management.
ManagementBaseObject outParams = classInstance.InvokeMethod("Create", inParams, null);bub
{
con = new ConnectionOptions();
con.Username = user;
con.Password = pass;
myscope = new ManagementScope(computername, con);
myscope.Connect();
myscope.Options.EnablePrivileges = true;
ManagementClass myprocess = new ManagementClass(myscope, new ManagementPath("Win32_Process"), null);
ManagementBaseObject mybase = myprocess.GetMethodParameters("Create");
mybase["CommandLine"] = "calc.exe";
ManagementBaseObject outbase = myprocess.InvokeMethod("Create", mybase, null);
}
catch (Exception ex)
{
string err = ex.Message.ToString();
}
whats wrong with this no erros but it doent do nything... i can get al other things like os info drive info etc...
IbeMale
I have not seen many examples of this but yes you can use WMI to do this. To get it working you might want to have a look at the vbscript versions on the technet script centre and see how they do it. I have converted several of these over in the past with out a problem.
alwo
classInstance["CurrentDirectory"] = exePath;
right before you invoke it.