1

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.

magicbennie
  • 423
  • 3
  • 8
  • 20
  • Please [edit] the question to include the relevant portions of your batch file. Problems asking about code you've written need to include the code; it's hard to answer questions about why it's not working when you don't show us what you're doing. – Ken White Aug 03 '13 at 02:00
  • possible duplicate of [How to run batch file from network share without "UNC path are not supported" message?](http://stackoverflow.com/questions/9013941/how-to-run-batch-file-from-network-share-without-unc-path-are-not-supported-me) – shf301 Aug 03 '13 at 02:10
  • I don't think its a duplicate... – magicbennie Aug 03 '13 at 02:33
  • which line makes an error? – Endoro Aug 03 '13 at 05:55
  • It think when the batch file starts up it notices it running on network drive and spit out an error. Or maybe its when you do something with the cd command that it notices the UNC path and gives it error. Either way, its bloody annoying :P – magicbennie Aug 03 '13 at 10:16

2 Answers2

3

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.

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • 1
    Minecraft gamer often change the `APPDATA` variable, usually it works. But to start the game, the current directory must also be set to `...\.minecraft\bin`. I guess, this might be a Java or Minecraft issue, not a batch one. – Endoro Aug 03 '13 at 08:29
  • Thank you! Works perfectly! And yes, the appdata variable being changed to a custom location is intentional, it allows the game to be portable, not just being confined to the appdata folder. @endoro the third line from the bottom of the batch code changes the cd to the bin folder of the game, then in the next line it actually starts the game itself. :) – magicbennie Aug 03 '13 at 10:12
0

Add this line as one of the first few lines in your program (before you access any files/folders).

pushd %~dp0
RGuggisberg
  • 4,630
  • 2
  • 18
  • 27
  • Does this pushd just the bat file, or the whole folder its in? Because I need it to take the whole folder as well. – magicbennie Aug 10 '13 at 04:25
  • For educational reasons You should add 3 lines. 1. ECHO.CD=%CD% 2. PUSHD 3. ECHO.CD=%CD% You will see that the original current directory is whatever and after the PUSHD the current directory will be what you probably originally expected (the directory from which you executed the bat file). – RGuggisberg Aug 19 '13 at 03:02