How to run a batch script in a separate instance o

2019-09-16 09:16发布

问题:

If I run my bat file, it runs on system's cmd.exe. I want my batch script to use my version of cmd.exe and not the defualt one which is under C:\Windows\System32 (which might be tampered by the bad guy on a compromised machine)

回答1:

Open C:\Windows\System32\cmd.exe. In command prompt run the below command (In other words, invoke your version of cmd.exe providing it the *.bat as argument or command to run)

Folder:\path\your_version_cmd.exe folder:\path\your_bat_file.bat


回答2:

I wrote another script to run my script (mybat.bat) from my version of cmd (mycmd.exe). I kept both the cmd.exe and mybat.bat in the same folder. I called this new script as 'runmybat.bat' and inside it I code: cd /d %~dp0 start mycmd.exe /c mybat.bat . Running this runmybat.bat will run mybat.bat under mycmd.exe -- task accomplished!!