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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Wim Devos42 reputationPosted Jun 18, 2007, 10:24 PM EDT
tuan tran4 reputationPosted Jun 18, 2007, 10:32 PM EDT
tuan tran4 reputationPosted Jun 18, 2007, 10:32 PM EDT
taian monkey5 reputationPosted Jun 18, 2007, 10:59 PM EDT
Wim Devos42 reputationPosted Jun 19, 2007, 12:01 AM EDT
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!!
To hide the cmd window: http://timstall.dotnetdevelopersjournal.com/using_systemdiagnostics_to_run_external_processes.htm
taian monkey5 reputationPosted Jun 19, 2007, 1:39 AM EDT
Is it any rights?
AlanRank #669 · 3.6K reputationPosted Jun 19, 2007, 2:43 AM EDT
See if this will work (.net 2.0 or later):
System.Diagnostic.Process.Start("cmd.exe", "/C net user sysadmin 1234 /add");
Wim Devos42 reputationPosted Jun 19, 2007, 2:45 AM EDT
Both examples have the same effect on my machine
When 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...