Solved How to create a shortcut to batch file one folder up

fhutt

New member
Local time
6:47 AM
Messages
18
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 My Computer

At a glance

Windows 7 Home Premium and Ultimate
Computer type
PC/Desktop
Computer Manufacturer/Model Number
HP
OS
Windows 7 Home Premium and Ultimate
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 My Computer

At a glance

Windows 10, Windows 8.1 Pro, Windows 7 Profes...
Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
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 My Computer

At a glance

Windows 7 Home Premium and Ultimate
Computer type
PC/Desktop
Computer Manufacturer/Model Number
HP
OS
Windows 7 Home Premium and Ultimate
Back
Top