EGRES Posted March 20, 2006 Posted March 20, 2006 anyone know how to get this in a cmd file ?i don't want to use any external programs
MHz Posted March 20, 2006 Posted March 20, 2006 At a command prompt, type CD /? to get more information on CD (CHDIR).
Delprat Posted March 20, 2006 Posted March 20, 2006 Use the %CD% variable... (read the end of the SET /? help page for others like this one)You have also %~dp0 for the full qualified path to the batch (read the end of the FOR /? help page for others like this one -- using "0")
gunsmokingman Posted March 20, 2006 Posted March 20, 2006 Here is Cmd that will show the Current Directory@Echo Off && CLS && Mode 65,5 && Color b2 && Title Current DirectorySet CD=%CD% Echo. && Echo The Current Dirctory && Echo ----^> %CD%Set /p = ----^> To Close Press Any Key ^<----
Delprat Posted March 20, 2006 Posted March 20, 2006 gunsmokingman, you should write "The Current Dirctory is :", and there will be nothing more to add(except a reg add... command to change the console font maybe ?)
Yzöwl Posted March 20, 2006 Posted March 20, 2006 Okay, technically in order to use %CD%, command extensions should be enabled. Since you have no idea as to whether they are or not, your batch file would need to make sure first.@SETLOCAL ENABLEEXTENSIONS &ECHO/ The current directory is %CD%That's it one line only!
gunsmokingman Posted March 21, 2006 Posted March 21, 2006 Here is a VBS script that gets the Current DirectoryDim Act, Cdir : Set Act = CreateObject("WScript.Shell") : Cdir = Act.CurrentDirectory Act.Popup "The Current Directory Is," & vbCrLf & Cdir, 15,"Current Directory", 0 + 32
Delprat Posted March 21, 2006 Posted March 21, 2006 Okay, technically in order to use %CD%, command extensions should be enabled. Since you have no idea as to whether they are or not, your batch file would need to make sure first.@SETLOCAL ENABLEEXTENSIONS &ECHO/ The current directory is %CD%That's it one line only!You should also check if the admin has not put restrictions on that, as said in the setlocal help page :@ECHO OFFVERIFY OTHER 2>NULSETLOCAL ENABLEEXTENSIONSIF NOT ERRORLEVEL 1 ECHO The current directory is %CD%
Yzöwl Posted March 21, 2006 Posted March 21, 2006 (edited) You should also check if the admin has not put restrictions on that, as said in the setlocal help pageThe verify method suggested is only for older versions of cmd.exe which do not set an errorlevel with setlocal.Could you tell me how as an Administrator I can restrict enabling of extensions, whereby setlocal enableextensions doesn't re-enable them. I have tried setting both HKLM and HKCU to disable in the registry, but my command shown above still works! Edited March 21, 2006 by Yzöwl
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now