G
Guest
public void sendKeysTest()
{
Process myProcess = Process.Start(@"C:\winnt\system32\cmd.exe");
SetForegroundWindow(myProcess.Handle);
if (myProcess.Responding)
SendKeys.SendWait("{ENTER}");
else
myProcess.Kill();
}
[DllImport("User32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
I have this code in my windowservice. Option to interact with desktop in
window service is also checked. When I click a button on the front end.
Inside the button click event, I call this method sendKeysTest, and
sendKeysTest is defined inside the window service. This program runs fine and
I can see cmd in my task manager that it is started, but I don't see the cmd
window. Is there any way I can see the cmd window. This code runs fine when I
run this code in windows form.
private void Button1_Click(object sender, System.EventArgs e)
{
try
{
runner.sendKeysTest();
}
catch(Exception ex)
{
string x = ex.Message;
}
}
Thanks,
Any help will be appreciated.
{
Process myProcess = Process.Start(@"C:\winnt\system32\cmd.exe");
SetForegroundWindow(myProcess.Handle);
if (myProcess.Responding)
SendKeys.SendWait("{ENTER}");
else
myProcess.Kill();
}
[DllImport("User32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
I have this code in my windowservice. Option to interact with desktop in
window service is also checked. When I click a button on the front end.
Inside the button click event, I call this method sendKeysTest, and
sendKeysTest is defined inside the window service. This program runs fine and
I can see cmd in my task manager that it is started, but I don't see the cmd
window. Is there any way I can see the cmd window. This code runs fine when I
run this code in windows form.
private void Button1_Click(object sender, System.EventArgs e)
{
try
{
runner.sendKeysTest();
}
catch(Exception ex)
{
string x = ex.Message;
}
}
Thanks,
Any help will be appreciated.