cmd - C# run PStool from FORM -
i want run pstool windows form. tried code:
system.diagnostics.process process = new system.diagnostics.process(); system.diagnostics.processstartinfo startinfo = new system.diagnostics.processstartinfo(); startinfo.windowstyle = system.diagnostics.processwindowstyle.normal; startinfo.filename = "cmd.exe"; startinfo.arguments = @"c:\\pstools\\psexec.exe \\\\" + dnsname+" cmd"; process.startinfo = startinfo; process.start();
but open command lint , not running command:"c:\pstools\psexec.exe \\" + dnsname+" cmd"
what doing wrong?
you can directly executed psexec setting it's exe filename. arguments accepted psexec can go in arguments property, so:
startinfo.filename = @"c:\pstools\psexec.exe"; startinfo.arguments = string.format(@"\\{0} cmd", dnsname);
keep in mind once indicated @ you're after verbatim string no longer need escape back-slashes.
Comments
Post a Comment