Problem with batch file (choice)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
progamergalil
Posts: 1
Joined: 19 Sep 2017 10:55

Problem with batch file (choice)

#1 Post by progamergalil » 19 Sep 2017 11:03

Hi,
I 've created a project with batch files...
When I've finished this all worked good, but now if I start the index file (the file that start the program) he says me that choice doesn't exist... :shock:
A few months ago it worked on double click, now it doesn't work :cry:
If I start it clicking "start as an administrator" choice works, but it has another problems (ex. other batch files location)...
Can you help me?
What is happened???
Thanks and sorry for the bad english.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Problem with batch file (choice)

#2 Post by aGerman » 19 Sep 2017 12:14

Can you help me?

No because you didn't provide the code that causes this error.
Hint: Did you overwrite system variables like PATH?

Steffen

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Problem with batch file (choice)

#3 Post by dbenham » 19 Sep 2017 12:37

Your PATH environment variable has likely been overwritten or corrupted. The source of that problem may be within your failing script, or it could be elsewhere.

pieh-ejdsch
Posts: 240
Joined: 04 Mar 2014 11:14
Location: germany

Re: Problem with batch file (choice)

#4 Post by pieh-ejdsch » 19 Sep 2017 15:33

Hello,
if you start your batch by double click, it will run in the current directory where the batch is on it.
your batch will find all proccesses and programs you start in batch with "program parameters ...",
or all relative Filenames - because they are present in this directory.
This corresponds to the command: "pushD directoryName" to set the work directory.
All relatively specified path and file names are then resolved.
Or in Variable "path" there is a reference to this directory, which is searched for the application
and executes the application when found.

if you start this batch as an administrator the current directory that work
this batch in it is: "%windir%\system32%", the application cant be found in
this directory if is not present in it or in "%path%".
The relative paths are no longer found or solved correctly.

in order to start this application from any directory, you must add this application directory
into the "Path" variable And use Pushd WorkingDir.

Note: if you start as an administrator an use: pushd "WorkingDirectory" (in qoutes)
it is useful to take a line like this one:

Code: Select all

if . == . pushd "working Directory"


Phil

Post Reply