Reputation: 2351
Ok so I was making my own little command prompt for my own personal use and I have been fighting to make it work for the past 2 hours. Here is what I have done:
@echo off
set /p labnum="Enter Lab Numnber:"
set labdir=C:\Users\BLAHBLAHBLAH\Dir\Lab-
set labdir2="%labdir%%labnum%"
cd labdir2
:cmd
set /p cmd=">"
%cmd%
cls
goto cmd
I basically want to be able to change the path before each "session" But every time the cd labdir2 command is executed, my computer whines, "The system cannot find the path specified." And I know FOR SURE that the directory exists! I have pasted the text straight from windows explorer. Any and all help is appreciated. Thank you!
Upvotes: 0
Views: 247
Reputation:
The error is here:
cd labdir2
that changes to a directory called labdir2
, but you want to change to a directory indicated by the contents of the variable:
cd %labdir2%
to make sure you can cope with special characters I'd enclose it with double quotes:
cd "%labdir2%"
You might even want to include the /d swith with the cd
command to make sure that you also change the current drive. So the final version should be:
cd /d "%labdir2%"
Upvotes: 3