bwz
asked on
Using System.Management.ManagementPath
Hi,
im using System.Management for access to some machine and run a command.
the connection work and also the execute command but my problem is when
i try to run a command file from another location that not recognize in the path variable enviroment
it's cannot been done.
my problems is how to make the command to open from my input location like for example:
D:\Projects\IAI Migration\Deployment\DocSi teExport.
my relative code is:
...
...
...
path = new System.Management.Manageme ntPath("\\ \\" + MachineName + "\\root\\cimv2:Win32_Proce ss");
scope = new System.Management.Manageme ntScope(pa th, options);
scope.Connect();
opt = new System.Management.ObjectGe tOptions() ;
classInstance = new System.Management.Manageme ntClass(sc ope, path, opt);
inParams = classInstance.GetMethodPar ameters("C reate");
inParams["CommandLine"] = Command;
...
...
...
thanks for the help :)
im using System.Management for access to some machine and run a command.
the connection work and also the execute command but my problem is when
i try to run a command file from another location that not recognize in the path variable enviroment
it's cannot been done.
my problems is how to make the command to open from my input location like for example:
D:\Projects\IAI Migration\Deployment\DocSi
my relative code is:
...
...
...
path = new System.Management.Manageme
scope = new System.Management.Manageme
scope.Connect();
opt = new System.Management.ObjectGe
classInstance = new System.Management.Manageme
inParams = classInstance.GetMethodPar
inParams["CommandLine"] = Command;
...
...
...
thanks for the help :)
ASKER
hi,
you mean that i config the path location after this line:
classInstance = new System.Management.Manageme ntClass(sc ope, path, opt); ?
i'm not sure that i got your poiint.
you mean that i config the path location after this line:
classInstance = new System.Management.Manageme
i'm not sure that i got your poiint.
Oops, I did it again :((
What is the problem that you are having opening the process on the remote machine?
I came up with this example class to try a slightly different approach:
using System;
using System.Management;
public class Win32_Process
{
public static void RunCommand(string commandLine, string machineName, string userName, string password)
{
ManagementPath path = new ManagementPath(@"\\" + machineName + @"\root\cimv2:Win32_Proces s");
ConnectionOptions options = new ConnectionOptions();
options.Username = userName;
options.Password = password;
options.Impersonation = ImpersonationLevel.Imperso nate;
options.Authentication = AuthenticationLevel.Packet Privacy;
ManagementScope scope = new ManagementScope(path, options);
ManagementClass classInstance = new ManagementClass(scope, path, new ObjectGetOptions());
classInstance.InvokeMethod ("Create", new object[] { commandLine });
}
}
Bob
What is the problem that you are having opening the process on the remote machine?
I came up with this example class to try a slightly different approach:
using System;
using System.Management;
public class Win32_Process
{
public static void RunCommand(string commandLine, string machineName, string userName, string password)
{
ManagementPath path = new ManagementPath(@"\\" + machineName + @"\root\cimv2:Win32_Proces
ConnectionOptions options = new ConnectionOptions();
options.Username = userName;
options.Password = password;
options.Impersonation = ImpersonationLevel.Imperso
options.Authentication = AuthenticationLevel.Packet
ManagementScope scope = new ManagementScope(path, options);
ManagementClass classInstance = new ManagementClass(scope, path, new ObjectGetOptions());
classInstance.InvokeMethod
}
}
Bob
ASKER
ok, thanks
i will check it on sunday, bu tell me please only one more things
what shoult i insert to path string?
can i pass this line for example ?" D:\Projects\IAI Migration\Deployment\DocSi teExport "
thanks again.
i will check it on sunday, bu tell me please only one more things
what shoult i insert to path string?
can i pass this line for example ?" D:\Projects\IAI Migration\Deployment\DocSi
thanks again.
Is 'DocSiteExport' the executable?
Bob
Bob
ASKER
no its the part of the path.
i'm finally run a command file the exists in that path
i'm finally run a command file the exists in that path
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yea,
i'm actually did it and it's work (run with the full path) but i thought that there is another way.
becaue i'm got a different behaviour when i run it from the machine and run it from the c# program.
(but it's another issue i gess).
i'm actually did it and it's work (run with the full path) but i thought that there is another way.
becaue i'm got a different behaviour when i run it from the machine and run it from the c# program.
(but it's another issue i gess).
Bob