I am making a batch Application to open other Applications and Websites, I ran into a problem when making it, the application does not open unless it is within the same folder as the batch file, however upon later inspection it seems this is an incompatibility with one of the programs within it.
CD "%userprofile%DesktopMultiBatchPlace applications here"
start Glyph.exe
This code works, only if it is within the same folder.
if %selector% == 7 start GlyphClient.exe
How do I launch it from an external folder?
Here is the full code.
@echo off
@title Multi Tool
color 0c
:title
echo ---------------------------------------------------------------
echo -------------------MultiTool by michaelukz---------------------
echo ---------------------------------------------------------------
pause
:select1
echo ---------------------------------------------------------------
echo ------------------------Selection tool-------------------------
echo ---------------------------------------------------------------
echo [1] Website selection
echo [2] Application selection
echo [3] Calculator
echo [4] Clock [Updates every minute]
echo [E] Exit
CHOICE /C:1234E
goto action%errorlevel%
:action1
echo Website selection chosen
goto websel
:websel
echo ---------------------------------------------------------------
echo ----------------------Choose your Website----------------------
echo ---------------------------------------------------------------
echo [1] Google.com
echo [2] Minecraft.net
echo [3] Kryptocraft.net
echo [4] Amazon.co.uk
echo [5] Virmach.com Client area
echo [6] xpaw.ru
echo [7] twitter.com
echo [8] Youtube
echo [9] Exit prompt
CHOICE /C:123456789
goto web%errorlevel%
cls
:web1
echo Starting Google.com
start www.google.com
goto title
:web2
echo Starting Minecraft.net
start www.minecraft.net
goto title
:web3
echo Starting kryptocraft.net
start www.kryptocraft.net
goto title
:web4
echo Starting Amazon.co.uk
start www.amazon.co.uk
goto title
:web5
echo Starting Virmach Client panel
start www.virmach.com/manage/clientarea.php
goto title
:web6
echo Starting xpaw.ru
start www.xpaw.ru/mcstatus
goto title
:web7
echo Starting Twitter.com
start www.twitter.com
goto title
:web8
echo Starting Youtube.com
start www.youtube.com
goto title
:web9
echo Going to Exit prompt
goto extprompt
:action2
echo Application selection chosen
goto appsel
:appsel
echo ---------------------------------------------------------------
echo --------------------Choose your application--------------------
echo ---------------------------------------------------------------
echo [1] Glyph
echo [2] Photoshop
echo [3] Nero video 2015
echo [4] Mozilla firefox
echo [5] Task manager
echo [6] Notepad++
echo [7] Minecraft
echo [8] FTB Launcher
echo [9] ATLauncher
echo [Q] Exit Prompt
CHOICE /C:123456789Q
goto app%errorlevel%
cls
:app1
echo Launching Glyph
PUSHD "%userprofile%DesktopMultiBatchPlace applications here"
START GlyphClient.exe
POPD
goto title
3
Answers
You can change your
cd
command tocd /d ...
as in the first form the current drive is not changed and if the program and batch file are in different drives the program will not be found.Or if you know the full path to the application, you can use
Your question is not very clear on what’s not working (or possibly you didn’t provide enough code).
However, the code below might solve your problem:
The more normal way to start programs is to specify full paths. In fact that is the only SECURE way.
So to start notepad (and start is only needed because it’s in a bat file – omit start if typing – why? type
start /?
)or if using paths with spaces (have to specify window title if using quotes in command line)
There is no need to change directories in Windows to run programs. It is designed that way.