I have the following batch file:

for /f "delims=" %%x in (path.txt) do set path=%%x
set address=62.75.218.30:14567
start bf1942.exe

With path.txt file containing the path to the executable. Once I run the batch file I am prompted if I want to allow BF1942.exe to make changes to this computer (user account control). Once I select 'yes' nothing happens. Similarly when I launch BF1942.exe by double clicking on the icon I get the same prompt but the game launches after I give permission.

Edit: I did some investigation. When I moved the path.txt and the batch file into my Bf1942 folder and ran the batch file this worked. So the problem has something to do where the file is located.

2

There are 2 answers

2
JosefZ On BEST ANSWER

Change the working directory (do not change the system environment variable path) as follows:

for /f "delims=" %%x in (path.txt) do set "myPath=%%~x"
set "address=62.75.218.30:14567"
pushd "%myPath%"
start "" bf1942.exe

or

set "address=62.75.218.30:14567"
for /f "delims=" %%x in (path.txt) do (
    pushd "%%~x"
    start "" bf1942.exe
)

Resources (required reading):

0
aphoria On

You can either move your batch file to the same folder as the executable or specify the full path to the executable in the batch file.

For example:

start c:\Bf1942\bf1942.exe

Also, you shouldn't use path as a variable name. There is a system environment variable named path and your batch is overwriting it. Change yours to myPath or something else.