2

Below is code for a batch file, loosely based on something i found on the internet. Ultimately, I'm trying to call one of two different batch files. It doesn't seem to acknowledge Bob'sbatchfile.bat. The file name and location are correct. Any ideas how to make the first instance work? I haven't started working on the second instance yet.

@ECHO OFF
CLS
ECHO 1.In office startup
ECHO 2.Out of office startup
ECHO.

CHOICE /C 12 /M "Enter your choice:"

:: Note - list ERRORLEVELS in decreasing order
IF ERRORLEVEL 2 GOTO OutOfOffice
IF ERRORLEVEL 1 GOTO InOffice

:InOffice
ECHO InOffice 
cd "\C:\Users\usdeprha\Localdocuments\Startupfiles\"
call "Bob'sbatchfile.bat"
pause
GOTO End

:OutOfOffice
ECHO "Out of office"

::start cmd /c C:\Users\usdeprha\Localdocuments\Startupfiles\Bob'sbatchfile.bat
GOTO End
END

I tried the code above. I've tried cd call"\C:\Users\usdeprha\Localdocuments\Startupfiles"Bob'sbatchfile.bat" None seem to work.

2
  • 3
    Try removing the leading "\" in the path. Commented Jun 23 at 12:58
  • 2
    plus add /d to also change the drive (if applicable): cd /d "c:\users\etc Commented Jun 23 at 13:42

1 Answer 1

1

You have \C:\... In your code, and use the absolute location via call.

It should be something like this:

@ECHO OFF
CLS
ECHO 1. In office startup
ECHO 2. Out of office startup
ECHO.
CHOICE /C 12 /M "Enter your choice:"

:: Note - list ERRORLEVELS in decreasing order

IF ERRORLEVEL 2 GOTO OutOfOffice
IF ERRORLEVEL 1 GOTO InOffice
:InOffice
ECHO InOffice
call "C:\Users\usdeprha\Localdocuments\Startupfiles\Bob'sbatchfile.bat"
pause
GOTO End
:OutOfOffice
ECHO Out of office

:: You can add another call here later

GOTO End
:End
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.