not used in forms, in web site , I want to call a dos command ,such as net user sysadmin 1234 /add , I using:
System.Diagnostic.Process.Start(@"net user sysadmin 1234 /add ");
but this calling is failed! why! thanks a lot!
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Wim DevosPosted Jun 19, 2007, 6:45 AM
Both examples have the same effect on my machine
System.Diagnostics.Process.Start("net", @"user username sysadmin /add "); System.Diagnostics.Process.Start("cmd.exe", "/C net username sysadmin /add");Though there is a difference in the orderWhen I set user sysadmin 1234
and i go to commandprompt and type: net user
no new users are listed, though when I check in controlpanel-users sysadmin is added.
When I set user 1234 sysadmin
and i go to commandprompt and type: net user
a new user called 1234 is listed, this is confirmed in controlpanel-users
Maybe this info could help you verify if your code is working or not...
AlanPosted Jun 19, 2007, 6:43 AM
See if this will work (.net 2.0 or later):
System.Diagnostic.Process.Start("cmd.exe", "/C net user sysadmin 1234 /add");
taian monkeyPosted Jun 19, 2007, 5:39 AM
Is it any rights?
Wim DevosPosted Jun 19, 2007, 4:01 AM
But you have to split up the arguments. I mean first set the name of the process (net) and then the arguments. Btw look at the syntax!!
System.Diagnostics.Process.Start("net", @"user username sysadmin /add ");To hide the cmd window: http://timstall.dotnetdevelopersjournal.com/using_systemdiagnostics_to_run_external_processes.htm
taian monkeyPosted Jun 19, 2007, 2:59 AM
tuan tranPosted Jun 19, 2007, 2:32 AM
tuan tranPosted Jun 19, 2007, 2:32 AM
Wim DevosPosted Jun 19, 2007, 2:24 AM