Running an .exe after another closes using .bat file - windows

I'm playing an old game that conflicts with the Windows Graphical Shell for Windows 7 and doesn't allow it to display properly so I simply go into Task Manager (TM) and close explorer.exe and the game displays fine but in order for me to enable explorer.exe I need to go into TM and start a new task for it to come back. I was wonder if there was a way to write a .Bat file that would kill explorer.exe launch my game and once the game closes it would simply run the task for me instead of manually needing to turn it back on.
taskkill /f /IM explorer.exe
start CNC95Launcher.exe
this is what i have so far

The start causes windows to launch your program asynchronously - that is, it will start it, then continue with the next instruction without waiting for your app to close.
Try this:
taskkill /f /IM explorer.exe
start /wait CNC95Launcher.exe
start explorer.exe
You probably don't actually need the start for explorer, because it's that kind program.

I use this (on window 7):
taskkill /F /IM Explorer.exe
*.exe
Start explorer.exe
replace * with the exe name that launches the actual game not a pre launch menu and save as .bat in the same folder directory.
It works for Star Wars Galactic Battlegrounds and AoE which can suffer weird colour issues if explorer runs.

Related

cmd script that restarts explorer doesn't restore taskbar and desktop icons

The Win10 taskbar sometimes stops autohiding (due to conditions covered elsewhere). A common fix is to start the Task mgr, kill Explorer, then File/Run new task/explorer.exe.
I'd like to do this via a batch script. However, this code:
taskkill /f /IM explorer.exe
timeout <some number> [if this was necessary]
c:\windows\explorer.exe [or start explorer.exe]
only starts the File Explorer. It does not re-establish desktop icons nor the taskbar. How can a batch script emulate what the taskmgr's run new task does?
Tnx

Closing only a window of an active application via .bat file

I am looking for a solution to close a window and leave the .exe running.
The .bat file:
#echo off
TITLE Bejelentkezes ujrainditasa
TASKKILL /F /im eszig-eid.exe
TASKKILL /F /im eszig-cmu.exe
start /d "C:\Program Files (x86)\ESZEMELYI\eSzemelyi_Kliens" eszig-cmu.exe
So, the eszig-cmu.exe must stay running, but when the code executes it opens the window of the program, and I don't need it. I want to close only the window of the application, like how I mentioned and leave the .exe (the active program) running! I also apply the solution in PowerShell! I only curious about the solution!

Restart explorer when prompt is started as adminstrator on windows 8 don't work

I need to restart explorer.exe after my application is installed. I'm currently using:
taskkill /f /im explorer.exe
start explorer.exe
That works ok on windows 7, with administrator or standard user, but when I try this on windows 8 as a standard user, the command just kills the explorer and doesn't restart it.
This happens because the command line is called as administrator, even with the standard user. Then the explorer doesn't restart.
Any thoughts about how to solve this?
The code should work but since I'm not using win8 (no thanks) can not diagnose.
But some I can offer.
This may work (time needed to unload some handlers) And double tried with or without start (yes it differs in some software, don't know win8)
taskkill /f /im explorer.exe
timeout 7
start "" explorer.exe
timeout 2
explorer.exe
explorer.exe keeps many handlers, shell stuff etc. One of those can cause trouble. Try also to disable them and test again
If not you can also try reexplorer tool to do the same. Maybe they considered this kind of situations while coding.
All bests

My batch file is closing a program too early

Thank you, for those whom took the time to read my question. I am a gamer and would like to execute a few things. First, I would like to Trigger a batch file when I click a program, how do you do that or is it even possible? Basically, activating a game, triggers the batch file.
NOw for the batch file problem, I want to execute Xpadder when I activate games (this is an mmo) and when I close the game I want Xpadder's process/service to close. Ultimately, it's auto trigger,activate,wait,terminate.
That's kind of the process I want it to go if all can be done.
Batch File:
#echo off
start "Blade" "C:\Users\user\Documents\Blade.xpadderprofile" Blade.xpadderprofile
ECHO Blade.xpadderprofile STARTED
start /w "C:\Program Files (x86)\game\games.exe" games.exe
ECHO games STARTED
taskkill /f /im Xpadder.exe
This actually works but the problem is there are two ".exe" files with mmo's. I'll start the game and it would close Xpadder too early because one launcher starts another launcher/client. Xpadder works for the first launcher but the first launcher closes so the game will start. I hope I am explaining myself clear enough.
Reference link: How to automatically close App_A when I close App_B using batchfile
Essentially, this is the same question I have but it's not very clear. What is the batch code to get Xpadder to stay on until the second launcher/client is closed not the first one?
P.S
The game has to open through the launcher then into the second launcher/client or it will not work.
here is the other clients name and path i think:
C:\Program Files (x86)\game\gamer\bin\gam.exe
How about the use of the PsExec, a small MS ulility? Using it, your batch should work:
cmd /c psexec -d "Blade" "C:\Users\user\Documents\Blade.xpadderprofile" Blade.xpadderprofile
start /w "C:\Program Files (x86)\game\games.exe" games.exe
taskkill /f /im Xpadder.exe
The file psexec.exe must be placed in folder enlisted in the system variable WINDIR or PATH, or, otherwise, you should call it with its full path, eg. *C:\Program Files\Others\pstools.exe".
You can add #echo off, salt, pepper or some green Tabasco if you have mon€y for this :D

How to stop a running process during an wise installation based un-install?

when i unwsied a project,if the main program of the project is running, then the un-install del all the floders and files except the main program.
how can i do,when i unwise a project if the main program is running .i want alert a dialog "are you sure to un-install this project when xxx.exe is running".
thanks.
Use a batch file to kill the process, like:
taskkill /IM programname.exe
It will prompt the user are they sure or ask if they want to save changes. Use /F to force the process to close.

Resources