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)
2 Answers
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!!
Comments
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 4 Comments
user3806770
Thanks Rahul! I wanted to automate this, but the issue is I cannot invoke another cmd.exe from the original MS cmd.exe it gives me a message saying 'All rights reserved'. So what I can do is run my version of cmd and type the bat file name. But I wanted it to automate it, that is include the cmd path to use in my batch script somehow..
Rahul
Well even if you include the same command as in my answer in your bat file and presume that once you double click on
*.bat it will invoke your version of cmd and execute the batch script ... NO that ain't happening. AFAIK, the moment you click and execute .bat .. it will default to cmd.exe and I believe you can't change that.user3806770
Okay, I wrote another script to run my first script as "cd /d %~dp0 start mycmd.exe /c my.bat" Now when I run this script, it runs another script in my version on cmd.exe
Rahul
Not sure I understood. Are you asking a question (OR) saying that you have found the solution? sounds like you have got it working .. that's great. If you think my answer helped you to reach to your solution then consider accepting it.