Reputation: 523
When I run a batch file on a network drive, i get the "UNC Paths not supported" error.
I want to store the current directory of the batch file in a variable so i can switch to it via the pushd
command, before the current directory changes to "C:\Windows".
Sorry if I missed something!
EDIT:
Heres the code:
@echo off
SETLOCAL EnableExtensions
title School Minecraft Hunger Games Launcher
set appdata=%cd%\core
set usrname=%USERNAME%
:lol
cls
set choice=
echo -------------------------------------------------------------------------------
echo School Minecraft Launcher v4.2
echo Minecraft Version: 1.5.2
echo -------------------------------------------------------------------------------
echo Logging in with the name "%usrname%". Is this correct? (y/n)
set /p choice=
if "%choice%"=="y" goto check
if "%choice%"=="yes" goto check
if "%choice%"=="n" goto argue
if "%choice%"=="no" goto argue
echo.
echo That is not a recognized command, Press enter to try again.
pause > nul
goto lol
:argue
cls
set provide2=
echo To change your ingame username, please provide the override password:
echo.
echo Type "back" to cancel.
echo.
set /p provide2=Password:
if "%provide2%"=="changename" goto enternewname
if "%provide2%"=="back" goto lol
echo.
echo Incorrect Password.
echo.
echo Press enter to try again...
pause > nul
goto argue
:enternewname
cls
echo Please enter new name, then press enter:
set /p usrname=
goto lol
:check
cls
if "%usrname%"=="user1" set knee=watermelon
if "%usrname%"=="user2" set knee=computer
if "%usrname%"=="user3" set knee=fish
if "%usrname%"=="user4" set knee=kittens
:final
if "%knee%"=="" goto rungame
cls
set provide=
echo -------------------------------------------------------------------------------
echo School Minecraft Launcher v4a
echo Minecraft Version: 1.5.2
echo -------------------------------------------------------------------------------
echo You are trying to login as an admin. Please provide your password.
echo.
echo Username: %usrname%
set /p provide=Password:
if "%knee%"=="%provide%" goto rungame
echo.
echo Incorrect password.
echo.
echo Press enter to exit...
pause > nul
exit
:rungame
pushd "%appdata%\.minecraft\bin"
start javaw -cp minecraft.jar;lwjgl.jar;lwjgl_util.jar -Djava.library.path="natives" net.minecraft.client.Minecraft "%usrname%"
exit
It is supposed to run wherever you put it, so long as you have included a folder called 'core' that contains the games files. Normally it would be: %cd%\core
. If you look right down at the bottom of the code, you see it needs to change the directory to: %cd%\core\.minecraft\bin
to start the game... But without the current directory variable, I cant do that.
Upvotes: 1
Views: 3643
Reputation: 4750
Add this line as one of the first few lines in your program (before you access any files/folders).
pushd %~dp0
Upvotes: 0
Reputation: 80023
setting the directory of the batchfile is normally accomplished by
set "dirofbatch=%~dp0"
(which will include the terminal-\
)
APPDATA
is one of windows' reserved names - established by the system for each BATCH session. It may be that its value is assumed by some process, and you've set to to somewhere unexpected. I'd suggest you change that variablename to something else.
Similarly, choice
is a batch keyword - I'd suggest you make another er, choice, of name. This probably won't actually affect the batch, just a matter of avoiding pitfalls.
Upvotes: 3