Batch command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
langancm
Posts: 1
Joined: 07 Feb 2022 11:47

Batch command

#1 Post by langancm » 07 Feb 2022 12:10

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

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Batch command

#2 Post by penpen » 07 Feb 2022 13:25

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

Maylow
Posts: 35
Joined: 15 Sep 2019 05:33

Re: Batch command

#3 Post by Maylow » 13 Feb 2022 22:57

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:

Post Reply