Making a "process_ending.exe".
Moderator: Moderators
-
Mikeyman64
- Posts: 493
- Joined: Tue Feb 21, 2006 5:06 pm
- Location: End of the World, AWKI
- Contact:
Making a "process_ending.exe".
How do I go about making an executing file that closes a certain process? Or better yet, closes a process and then opens it back up again.
-
Mikeyman64
- Posts: 493
- Joined: Tue Feb 21, 2006 5:06 pm
- Location: End of the World, AWKI
- Contact:
Couple of ways.
That will close the program but will ask if you want to save (e.g. Word, Notepad). If you want to close it forcefully:
Haven't tested any of this, but it should work fine.
If you need any other language, just ask.
- BATCH Code (easiest):
Code: Select all
@echo off
taskkill /IM TaskName.exe- BATCH Code Force:
Code: Select all
@echo off
taskkill /F /IM TaskName.exe- C++:
Code: Select all
#include <cstdio>
#include <stdlib.h>
int main()
{
system("taskkill /IM TaskName.exe");
return 0;
}- C++ Force:
Code: Select all
#include <cstdio>
#include <stdlib.h>
int main()
{
system("taskkill /F /IM TaskName.exe");
return 0;
}Haven't tested any of this, but it should work fine.
If you need any other language, just ask.
-
Mikeyman64
- Posts: 493
- Joined: Tue Feb 21, 2006 5:06 pm
- Location: End of the World, AWKI
- Contact:
-
bicostp
- Moderator
- Posts: 10491
- Joined: Mon Mar 07, 2005 5:47 pm
- Steam ID: bicostp
- Location: Spamalot
- Contact:
No, you need a C++ compiler.
You can make a batch file the way you described. (Write it in Notepad and save it as a .BAT file.) It will work without any compilation.
EDIT: Yes you can. Just add a line to the batch file that runs the program. (Just put in the full path name, such as C:\WINDOWS\SYSTEM32\SOL.EXE for solitaire.)
You can make a batch file the way you described. (Write it in Notepad and save it as a .BAT file.) It will work without any compilation.
EDIT: Yes you can. Just add a line to the batch file that runs the program. (Just put in the full path name, such as C:\WINDOWS\SYSTEM32\SOL.EXE for solitaire.)
Last edited by bicostp on Fri May 04, 2007 9:23 pm, edited 1 time in total.
Twitter
http://www.pcwgaming.com" onclick="window.open(this.href);return false;
If you want a Dropbox account, please use my referral link
http://www.pcwgaming.com" onclick="window.open(this.href);return false;
If you want a Dropbox account, please use my referral link
-
Mikeyman64
- Posts: 493
- Joined: Tue Feb 21, 2006 5:06 pm
- Location: End of the World, AWKI
- Contact:
-
Mikeyman64
- Posts: 493
- Joined: Tue Feb 21, 2006 5:06 pm
- Location: End of the World, AWKI
- Contact:
Yay! I figured it out myself! I feel smart!
"@echo off
taskkill /F /IM TaskName.exe
cd C:\windows\system32\
start SameTaskName.exe"
without quotes
Now, how would I do that in C++?
EDIT: I figured out that I really need it in C++ because the PC I'm making this for (my parents) is running XP Home which doesn't support taskkill.
"@echo off
taskkill /F /IM TaskName.exe
cd C:\windows\system32\
start SameTaskName.exe"
without quotes
Now, how would I do that in C++?
EDIT: I figured out that I really need it in C++ because the PC I'm making this for (my parents) is running XP Home which doesn't support taskkill.
Well, there's a extremely better way to do it, using registry and stuff, but this is fine enough. 
In C++, I am just using the "system" shell, which basically just makes your program act like a batch file or command prompt. You can also use C++ commands such as rename(), delete() (more in FileOperations.h).
So just...
Once again, untested. 
So why do you want to do this? What's the program's purpose?
In C++, I am just using the "system" shell, which basically just makes your program act like a batch file or command prompt. You can also use C++ commands such as rename(), delete() (more in FileOperations.h).
So just...
Code: Select all
#include <cstdio>
#include <stdlib.h>
int main()
{
system("taskkill /F /IM TaskName.exe");
system("cd C:\windows\system32\");
system("start SameTaskName.exe");
return 0;
}So why do you want to do this? What's the program's purpose?
-
Mikeyman64
- Posts: 493
- Joined: Tue Feb 21, 2006 5:06 pm
- Location: End of the World, AWKI
- Contact:
My dad's printer spooling service (spoolsv.exe) keeps locking up on him. I think it happens when a print project starts but doesn't finish and then someone else comes along and starts another print project and it gets all screwy, I've got 9 sib still in my house and that kind of thing will happen, and I found that if I close spoolsv.exe and then start it back up it works, so wanted to make my, un-technological, dad an easy way out of this. The first thing that came to my mind was and easy exe right there on the desktop.
Yikes! That was bad writing! I'm too tired to fix it though...zzzzzzzzz
Yikes! That was bad writing! I'm too tired to fix it though...zzzzzzzzz
That's like, the worst way ever! 
-Start > Run > regedit >
-HKEY_CURRENT_USER > Software > Microsoft > Windows > CurrentVersion > Run
-Delete the spoolsv.exe REG_SZ subkey entry. Just click it and press the delete key.
EDIT: Forgot to explain what it does. It will stop spoolsv.exe from booting up at the start of Windows.
-Start > Run > regedit >
-HKEY_CURRENT_USER > Software > Microsoft > Windows > CurrentVersion > Run
-Delete the spoolsv.exe REG_SZ subkey entry. Just click it and press the delete key.
EDIT: Forgot to explain what it does. It will stop spoolsv.exe from booting up at the start of Windows.
-
Mikeyman64
- Posts: 493
- Joined: Tue Feb 21, 2006 5:06 pm
- Location: End of the World, AWKI
- Contact:
If you lock down the computer with Deep Freeze nothing bad could go wrong.