Jump to content

Recommended Posts


Posted

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")

Posted

Here is Cmd that will show the Current Directory

@Echo Off && CLS && Mode 65,5 && Color b2 && Title Current Directory
Set CD=%CD%
Echo. && Echo The Current Dirctory && Echo ----^> %CD%
Set /p = ----^> To Close Press Any Key ^<----

Posted

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 ?)

;)

Posted

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!

Posted

Here is a VBS script that gets the Current Directory

Dim Act, Cdir : Set Act = CreateObject("WScript.Shell") : Cdir = Act.CurrentDirectory
Act.Popup "The Current Directory Is," & vbCrLf & Cdir, 15,"Current Directory", 0 + 32

Posted
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 OFF
VERIFY OTHER 2>NUL
SETLOCAL ENABLEEXTENSIONS
IF NOT ERRORLEVEL 1 ECHO The current directory is %CD%

:P

Posted (edited)
You should also check if the admin has not put restrictions on that, as said in the setlocal help page
The 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 by Yzöwl

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...