Can't change directory using cmd script
Posted: 08 Dec 2022 02:08
I can change directory fine if I manually type cd into cmd window, but I cannot get any cd command to work from a cmd file.
I know that I must be overlooking something basic and glaringly obvious, but I can't figure out what's going on.
For example:
If I type at the command prompt, it goes to the Windows folder on C:. However, If I put the same command in a cmd file and run it, then instead of changing directory I get an error message saying:
Every guide that I've looked up says that you change directories in scripts and batch files the same way that you do manually at the command prompt (i.e. using cd) so I therefore assumed that the problem must be something specific to my system (maybe a weird setting somewhere). To see if this was the case I tried to do the same thing in a virtual machine using a clean installed OS, but the same thing happened.
I use custom Start Menu shortcuts to launch certain console sessions, and I specify startup paths in the shortcut's Target field using a cd command and it works fine for all of them (even using variables such as: cd /D %userprofile% ) so I don't know why the exact same thing won't work from within a .cmd file.
Anyone have any suggestions for what the issue might be? (other than PBKAC).
Some info that may be of use:
I know that I must be overlooking something basic and glaringly obvious, but I can't figure out what's going on.
For example:
If I type
Code: Select all
cd /d "C:\Windows"
Code: Select all
'■@' is not recognized as an internal or external command,
operable program or batch file.
I use custom Start Menu shortcuts to launch certain console sessions, and I specify startup paths in the shortcut's Target field using a cd command and it works fine for all of them (even using variables such as: cd /D %userprofile% ) so I don't know why the exact same thing won't work from within a .cmd file.
Anyone have any suggestions for what the issue might be? (other than PBKAC).
Some info that may be of use:
Code: Select all
Date/Time format : (dd/mm/yy) 08/12/2022 8:05:13.29
__APPDIR__ : C:\Windows\system32\
ComSpec : C:\Windows\system32\cmd.exe
PathExt : .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Extensions : system: Enabled user: Enabled
Delayed expansion : system: Disabled user: Disabled
Locale name : en-GB Code Pages: OEM 850 ANSI 1252
DIR format : 08/12/2022 03:19 17,093,369,856 pagefile.sys
Permissions : Elevated Admin=Yes, Admin group=Yes
Missing from the tool collection: debug