进程中如何通过Process.Start()打开程序
做一个开启远程机器客户程序的程序,用Socket做,打开程序用Process.Start()做,调试模式下可以打开客户程序,正常打开exe文件时,就打不开客户程序。private void Form1_Load(object sender, EventArgs e)
{
Thread th = new Thread(new ThreadStart(NewMethod));
th.IsBackground = true;
th.Start();
}
private void NewMethod()
{
while (true)
{
try
{
int port = 2000;
string host = "192.168.0.60";
IPAddress ip = IPAddress.Parse(host);
IPEndPoint ipe = new IPEndPoint(ip, port);
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Bind(ipe);
s.Listen(20);
Socket temp = s.Accept();
Console.WriteLine("get a connect");
string revStr = "";
byte[] recvBytes = new byte[1024];
int bytes;
bytes = temp.Receive(recvBytes);
revStr += Encoding.ASCII.GetString(recvBytes).Replace("\0","");
if (revStr == "shutdown")
{
System.Diagnostics.Process.Start("cmd.exe", "shutdown -s -t 0");
}
if (revStr == "osk")
{
System.Diagnostics.Process.Start("osk.exe");
}
if (revStr == "notepad")
{
System.Diagnostics.Process.Start("osk.exe");
}
listBox1.Items.Add(DateTime.Now.ToString()+ " "+ revStr);
string sendStr = "OK,Client Send Message Successful!";
byte[] bs = Encoding.ASCII.GetBytes(sendStr);
temp.Send(bs, bs.Length, 0);
temp.Close();
s.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
} --------------------编程问答-------------------- 打不开是什么概念 --------------------编程问答-------------------- 权限问题? --------------------编程问答-------------------- 如果服务器端发送过来的命令为"osk",则客户端要打开屏幕键盘才对,现在是没反应,但在调试模式下就能打开 --------------------编程问答-------------------- PATH里面有没有%windir%\system32,另外,是否存在osk.exe文件? --------------------编程问答--------------------
path里面也有%windir%\system32,也存在osk.exe --------------------编程问答-------------------- 可以了 --------------------编程问答-------------------- --------------------编程问答-------------------- 想知道LZ是怎么做的.
补充:.NET技术 , C#