本文介绍了我只想打开cmd提示作为管理,之后我必须传递一些东西来创建服务,我的代码在下面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

处理myProcess = new Process();

myProcess.StartInfo.UseShellExecute = true;

myProcess.StartInfo.Verb =runas;

myProcess.StartInfo.FileName = @cmd.exe;



myProcess.EnableRaisingEvents = true;

myProcess.Start( );

string ramana =instsrv.exe++YourServiceName++ @D:\ WindowsService1.exe;

线程。睡眠(8000);

System.Windows.Forms.SendKeys.SendWait(ramana +{ENTER});



Thread.Sleep(3000);

// myProcess.Kill();

MessageBox.Show(完成......);



我尝试了什么:



cmd作为管理员打开但是如果cmd打开正常意味着sendkeys事件无效)它会工作



任何人都可以帮我解决这个问题



提前感谢

Process myProcess = new Process();
myProcess.StartInfo.UseShellExecute =true;
myProcess.StartInfo.Verb = "runas";
myProcess.StartInfo.FileName = @"cmd.exe";

myProcess.EnableRaisingEvents = true;
myProcess.Start();
string ramana = "instsrv.exe" + " "+"YourServiceName" + " " + @"D:\WindowsService1.exe";
Thread.Sleep(8000);
System.Windows.Forms.SendKeys.SendWait(ramana + "{ENTER}");

Thread.Sleep(3000);
// myProcess.Kill();
MessageBox.Show("done...");

What I have tried:

The cmd is opening as administation but sendkeys event not working ,if cmd open normally means(without administration ) it will work

can any one one help me out from this

thanks in advance

推荐答案



这篇关于我只想打开cmd提示作为管理,之后我必须传递一些东西来创建服务,我的代码在下面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:17