How to create a shortcut to batch file one folder up


  1. Posts : 18
    Windows 7 Home Premium and Ultimate
       #1

    How to create a shortcut to batch file one folder up


    Hello
    I have been trying to create a shortcut to launch a batch file one folder up from the shortcut location.
    I have been able to do this using and intermediate batch file in the same folder as the shortcut as follows:
    Intermediate.bat:
    @echo off
    FOR %%V IN ("%~dp0..\") DO set curdrv=%%~dpV
    start "" %curdrv%Oneup.bat

    And the shortcut target is:
    %windir%\system32\cmd.exe /c Intermediate.bat

    and the 'Start in' is left blank.

    This way I can move these folders anywhere on the drive or another drive and the shortcut still works.
    However, I would like to leave out the Intermediate.bat file and launch the Oneup.bat directly. I tried:
    %windir%\system32\cmd.exe /c FOR %%V IN ("%~dp0..\") DO set curdrv=%%~dpV && start "" %curdrv%Oneup.bat
    in the Target of the shortcut, but it doesn't work.
    Is there some trick to getting this to work?
    Thanks
      My Computer


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    Hey Fhutt,

    You can do the following for your shortcut's target.
    Code:
    cmd /c "start "" "..\Oneup.bat""
    And ensure that the 'Start in' field in the shortcut's Properties pane is empty.

    Alternatively, you may instead want to look in to symbolic links which do support relative paths.
      My Computer


  3. Posts : 18
    Windows 7 Home Premium and Ultimate
    Thread Starter
       #3

    Thank you. This is what I was looking for.
    Maybe some of the quotes would not be needed:
    cmd /c start "" "..\Oneup.bat"
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 04:51.
Find Us