tips.paddyonline.net

If you need tips & tricks, here they are...

  • Get current directory

    To get the current directory to use inside batch files.


    There is a very simple way to get the directory from a batch script file. CD environment variable stores the current directory of a command window session. Just run the command ‘echo %CD%’ and check it yourself.

    C:\Users\windmdline>echo The current directory is %CD%
    The current directory is C:\Users\wincmdline

    Or you can use a much better alternative

    %~dp0 is the variable you want.
    It outputs the drive and path of the batch file.
    EX1: C:\mydir\myfile.bat becomes C:\mydir\
    Ex2: @echo off
    Set SetupApp=WinaeroTweaker-0.17.0.0-setup.exe

    %SetupApp% /VERYSILENT /PORTABLE /DIR="%~dp0\wt_portable"
    exit
    Will create a new directory in the directory where you have the WinaeroTweaker-0.17.0.0-setup.exe file called wt_portable and run the WinaeroTweaker-0.17.0.0-setup.exe to create a portable extraction of all files.

    Here’s a MS reference, it works in thing other than Batch; like VBS SCCM, PS, shortcuts too.
    https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true

    Source: Here!

Please consider supporting our efforts.