问题描述
尊敬的先生/女士
我想制作一个密码重置程序..但是我的程序无法正常工作,因为问题是system()仅接受1个参数或string.以下是我的代码,请解决.
I want to make a password resseting program.. but my program is not working bcause the problem is the system() taking only 1 argument or string . following is my code please solve it if u can.
字符串帐户;
字符串密码;
//string []参数1 = {"/k net user" };
帐户= Convert.ToString(textBox1.Text);
密码= Convert.ToString(textBox2.Text);
string [] arguments1 = {"/k net user" };
System.Diagnostics.ProcessStartInfo proc =新的System.Diagnostics.ProcessStartInfo();
proc.FileName = @"C:\ windows \ system32 \ cmd.exe";
proc.Arguments = String.Format("{0} {1} {2}",argument1,account,password);
//proc.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
System.Diagnostics.Process.Start(proc);
string account;
string password;
//string[] argument1 = {"/k net user" };
account = Convert.ToString(textBox1.Text);
password = Convert.ToString(textBox2.Text);
string[] argument1 = { "/k net user" };
System.Diagnostics.ProcessStartInfo proc = new System.Diagnostics.ProcessStartInfo();
proc.FileName = @"C:\windows\system32\cmd.exe";
proc.Arguments = String.Format("{0} {1} {2}", argument1,account,password);
//proc.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
System.Diagnostics.Process.Start(proc);
我尝试了2种解决方法,但是并没有使用超过1个字符串或参数..所以请帮助我..谢谢..:)
I tried 2 solve in all ways but it not taking more than 1 string or arguments..so please help me..thank you.. :)
推荐答案
ProcessStartInfo psi = new ProcessStartInfo(@"C:\Windows\system32\net.exe");
psi.Arguments = "user myaccount mynewpassword";
Process.Start (psi);
请注意,当然,如果更改不是当前帐户的帐户密码,您的程序很可能需要提升的管理权限.
Note, of course, that quite likely your program will require elevated administrative privileges if changing the account's password that is not the current account.
这篇关于净使用者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!