Page 1 of 1

Batch command

Posted: 07 Feb 2022 12:10
by langancm
Good day,

new to Dos and batch files programming and have tried to figure this out without any luck.

I'm trying to run a batch file to open a dos command window (show it in Windows) and then have a pause. Once the keyboard is pressed change the directory to C:\Program Files (x86)\Symantec\Symantec Endpoint Protection showing the directory and then press the pause to exit.


This is what I have which doesn't work 100%. It opens two DOS windows one with the below and another one C:\Windows\system32>


start cmd.exe
pause
cd "C:\Program Files (x86)\Symantec\Symantec Endpoint Protection"
pause

Re: Batch command

Posted: 07 Feb 2022 13:25
by penpen
Batch is an interpreter language, which means that the interpreter is always loaded (which under windows typically is cmd.exe).
So, maybe your batch file but leaving out the first line ("start cmd.exe") is, what you are looking for.

penpen

Re: Batch command

Posted: 13 Feb 2022 22:57
by Maylow
This would do the trick:

Code: Select all

@echo off
pause
for %%b in ("C:\Program Files (x86)\Symantec\Symantec Endpoint Protection") do (
    start "Contents of Symantec Endpoint Protection" /wait "cmd" "/d /k dir /p /on "%%~sfb" & pause & exit
)
pause
exit /b
Hang on, never mind, didn't read the post itself well and the first reply which answers it already.
Must be getting late for me :oops: