I am in a pickel, I MUST start and stop the apache web server in
console mode. The only way to shut down apache cleaning is by
pressing <Ctrl>+C. I have tried everything I know and I cannot
duplicate that in C# code. This is what I have, which is NOT working:
[DllImport("Kernel32.dll")]
public static extern bool GenerateConsoleCtrlEvent(int ctrlEvent, int
processGroupId);
[DllImport("Kernel32.dll")]
public static extern int GetProcessId(IntPtr Process);
int processID = GetProcessId(process.Handle);
GenerateConsoleCtrlEvent(0, processID);
Of course, process IS the apache service the application started.
Anyone have any more thoughts? 4 6366
Have you tried:
System.Windows.Forms.SendKeys?
eg:
IWshRuntimeLibrary.WshShell Shell;
Shell.Run("calc");
Threading.Thread.Sleep(100);
Shell.AppActivate("Calculator");
Shell.SendKeys("101")
Sleep(500);
Shell.SendKeys("*");
or you could show it some tough love:
Process[] Processes = Process.GetProcessesByName("apache");
foreach( Process myProcess in Processes)
{
myProcess.CloseMainWindow(); //not so tough...
myProcess.Kill(); //Oh dear...... You can just imagin what this does.
}
I dont think PInvokes are required, but let me know how it goes :)
"ca******@gmail.com" wrote:
I am in a pickel, I MUST start and stop the apache web server in
console mode. The only way to shut down apache cleaning is by
pressing <Ctrl>+C. I have tried everything I know and I cannot
duplicate that in C# code. This is what I have, which is NOT working:
[DllImport("Kernel32.dll")]
public static extern bool GenerateConsoleCtrlEvent(int ctrlEvent, int
processGroupId);
[DllImport("Kernel32.dll")]
public static extern int GetProcessId(IntPtr Process);
int processID = GetProcessId(process.Handle);
GenerateConsoleCtrlEvent(0, processID);
Of course, process IS the apache service the application started.
Anyone have any more thoughts?
On Feb 1, 10:12 pm, TheMadHatter
<TheMadHat...@discussions.microsoft.comwrote:
Have you tried:
System.Windows.Forms.SendKeys?
eg:
IWshRuntimeLibrary.WshShell Shell;
Shell.Run("calc");
Threading.Thread.Sleep(100);
Shell.AppActivate("Calculator");
Shell.SendKeys("101")
Sleep(500);
Shell.SendKeys("*");
or you could show it some tough love:
Process[] Processes = Process.GetProcessesByName("apache");
foreach( Process myProcess in Processes)
{
myProcess.CloseMainWindow(); //not so tough...
myProcess.Kill(); //Oh dear...... You can just imagin what this does.
}
I dont think PInvokes are required, but let me know how it goes :)
I was doing the last thing you suggested, already, that is getting the
process by name and killing them all. The downside to that was that I
also had a develpment instance running as a service and it, too, was
killed.
What I had missed what the CloseMainWindow() call, this works like a
charm! The whole deal is that when you start one instance of apache,
it starts one or more children. When you Kill() the process you
started, the children keep running. But CloseMainWindow() sends the
right info to the parent apache and it closes the other servers
gracefully!
Thanks!
You were trying to kill children eh? LOL !!!
Anyhoo.....
Glad to be of some assistance.
"herc" wrote:
On Feb 1, 10:12 pm, TheMadHatter
<TheMadHat...@discussions.microsoft.comwrote:
Have you tried:
System.Windows.Forms.SendKeys?
eg:
IWshRuntimeLibrary.WshShell Shell;
Shell.Run("calc");
Threading.Thread.Sleep(100);
Shell.AppActivate("Calculator");
Shell.SendKeys("101")
Sleep(500);
Shell.SendKeys("*");
or you could show it some tough love:
Process[] Processes = Process.GetProcessesByName("apache");
foreach( Process myProcess in Processes)
{
myProcess.CloseMainWindow(); //not so tough...
myProcess.Kill(); //Oh dear...... You can just imagin what this does.
}
I dont think PInvokes are required, but let me know how it goes :)
I was doing the last thing you suggested, already, that is getting the
process by name and killing them all. The downside to that was that I
also had a develpment instance running as a service and it, too, was
killed.
What I had missed what the CloseMainWindow() call, this works like a
charm! The whole deal is that when you start one instance of apache,
it starts one or more children. When you Kill() the process you
started, the children keep running. But CloseMainWindow() sends the
right info to the parent apache and it closes the other servers
gracefully!
Thanks!
Actually, I ran into another interesting issue. When I launch apache
and tell it to hide the process window, CloseMainWindow() does nothing:
( I am assuming it is because there is no main window to close. Oh
well, I will simply minimize the window for early testing and before
release I will fix apache! The docs claim that you can lanuch another
instance to kill the one running, but it doesn't work, I will change
that! hehehehe
On Feb 5, 3:08 pm, TheMadHatter
<TheMadHat...@discussions.microsoft.comwrote:
You were trying to kill children eh? LOL !!!
Anyhoo.....
Glad to be of some assistance.
"herc" wrote:
What I had missed what the CloseMainWindow() call, this works like a
charm! The whole deal is that when you start one instance of apache,
it starts one or more children. When you Kill() the process you
started, the children keep running. But CloseMainWindow() sends the
right info to the parent apache and it closes the other servers
gracefully!
Thanks!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Per Magnus L?vold |
last post by:
Hi,
I am working with a simple Java program which communicates over the
serial port with a GSM modem.
Using Hypertermial, I can send messages and need to press control-z to
process the messages....
|
by: Scott |
last post by:
I am using a TCPIP connection to communicate over port 23 (telnet) to
a server,
and I am having to mimic normal command line interface you owuld see
in a telnet session (i.e. I have to write to...
|
by: PerryG |
last post by:
We have a .NET 1.1 client which is sending a gzipped soap request using
HttpWebRequest to an Apache server. The Apache server is using a the
'mod_deflate' server to decompress the incoming...
|
by: s99999999s2003 |
last post by:
hi
i have a program that works very similar to tail -f in Unix
It will need a Ctrl-C in order to break out of the program.
I wish to run this program using python (either thru os.system() or
some...
|
by: s99999999s2003 |
last post by:
hi
i have a program that works very similar to tail -f in Unix
It will need a Ctrl-C in order to break out of the program.
I wish to run this program using python (either thru os.system() or
some...
|
by: Daniel Clark |
last post by:
I have a Windows command line based application that only shuts down
cleanly if it sees "CTRL-C" on the console. I need to automate the
running of this application, but still allow the user sitting...
|
by: rhitam30111985 |
last post by:
Hi all .. i am trying to do something really weird ...
here is my code :
import os
os.system("mail -s test xxx@gmail.com asdaskdjkasdaasdad")
|
by: happyse27 |
last post by:
Hi All,
I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it...
|
by: ksheerasagar17 |
last post by:
Hello All,
Scenario: Sending an image through webservice as byte array to an Java webservice.
The Problem1: The webservice method image property expects (data type) SByte rather than Byte...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |