-2

I have below command and saved it as a .bat file.

taskkill /F /IM explorer.exe

start /realtime chrome.exe

now I want to add some further command so that upon closing google chrome Windows Explorer process gets started automatically.

  • add a `/wait` to the `start` command and as next line start explorer (with just `explorer.exe`) – Stephan Dec 17 '18 at 11:10
  • So, hi, and welcome to Stack Over Flow, this question have 2 commands, and this do is kill explorer and start chrome, ok, but in explanation, your need, I´m not sure if i understand, so, you need is in this sequence: 1) kill explorer, 2) start chrome, **still the same bat**, 3) see that chrome killed, 4) perform more tasks/commands, **in same bat**? there is? – Io-oI Dec 17 '18 at 22:24
  • @Stephan Sir, please combine my code and your code and paste it below in bold. Actually, I don't know where to add /wait command in batch file. So please provide complete code that I can use to create a new batch file. My computer processor is slow that's why I am using /realtime command. Is it good enough to use /high command instead of /realtime command. – Mukesh Kaswan Dec 19 '18 at 05:34

2 Answers2

0

use start /wait to wait until the started process is finished/exited. Then just execute explorer.exe

taskkill /F /IM explorer.exe
start /realtime /wait chrome.exe
explorer.exe

Note: I don't think, its a good idea to kill explorer or to start a browser as "realtime", but I see your point: being on a meager system you want to assign every available resource to the task to be done.

(But Chrome might not be the best choice in this case)

Stephan
  • 53,940
  • 10
  • 58
  • 91
0

Try the following with administrator privileges

start /min taskkill.exe /f /im explorer.exe 2>nul >nul && start "" /wait "%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe" && start "" /wait /realtime "%windir%\explorer.exe" && start "" /realtime "%windir%\system32\taskkill.exe" /f /im cmd.exe <nul

This final part: start "" /realtime "%windir%\system32\taskkill.exe" /f /im cmd.exe <nul, can be replace by call some_bat.bat <nul with all commands that you need to run.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Io-oI
  • 2,514
  • 3
  • 22
  • 29