Page 1 of 2

command retunrs no value even though entry exists

Posted: 09 Sep 2020 20:05
by Yanta
Recently I received some excellent support in reading a list of items from a text file and assigning the result to a variable.

However, it seems to be struggling with a single entry.

This is an abridged list of the games...

Code: Select all

Overwolf,D:\Program Files (x86)\Overwolf
Quake,I:\Program Files (x86)\Quake
AoE2DE,I:\Program Files (x86)\SteamLibrary2\steamapps\common\AoE2DE
Doom 64,I:\Program Files (x86)\SteamLibrary2\steamapps\common\Doom 64
Duke Nukem 3D,I:\Program Files (x86)\SteamLibrary2\steamapps\common\Duke Nukem 3D
GarrysMod,I:\Program Files (x86)\SteamLibrary2\steamapps\common\GarrysMod
Green Hell,I:\Program Files (x86)\SteamLibrary2\steamapps\common\Green Hell
Path of Exile,I:\Program Files (x86)\SteamLibrary2\steamapps\common\Path of Exile
We Went Back,I:\Program Files (x86)\SteamLibrary2\steamapps\common\We Went Back
Epic Games,D:\program files (x86)\Epic Games
Age2HD,E:\Program Files (x86)\Steam\steamapps\common\Age2HD
Counter-Strike Global Offensive,E:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive
dota 2 beta,E:\Program Files (x86)\Steam\steamapps\common\dota 2 beta
dota 2 test,E:\Program Files (x86)\Steam\steamapps\common\dota 2 test
Game Guru,E:\Program Files (x86)\Steam\steamapps\common\Game Guru
NBA 2K19,E:\Program Files (x86)\Steam\steamapps\common\NBA 2K19
PUBG,E:\Program Files (x86)\Steam\steamapps\common\PUBG
Rust,E:\Program Files (x86)\Steam\steamapps\common\Rust
Skyrim,E:\Program Files (x86)\Steam\steamapps\common\Skyrim
Skyrim Special Edition,E:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition
Steamworks Shared,E:\Program Files (x86)\Steam\steamapps\common\Steamworks Shared
Underlords,E:\Program Files (x86)\Steam\steamapps\common\Underlords
Battle.net,D:\Program Files(x86)\Battle.net
Runescape,D:\Program Files\Jagex\RuneScape Launcher
The command to retrieve the folder name is;

Code: Select all

Echo Checking for Runescape
for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do IF /I "%%a"=="Runescape" set GamePath=%%b
IF "%GamePath%"=="" Echo Empty path returned for Runescape
For Runescape and only Runescape GamePath is always empty.

Grabbing at straws, I even moved the entry higher in the list with no success.
I checked - there is no space at the end of the for line as this would cause it to fail.

Why would it fail only on this entry?

Re: command retunrs no value even though entry exists

Posted: 09 Sep 2020 21:15
by Squashman
Should we assume the Source Path variable is defined correctly?

Regardless, I copied and pasted your input file and your code exactly and substituted my own source path and it works just fine.

Re: command retunrs no value even though entry exists

Posted: 11 Sep 2020 00:13
by Yanta
Yes. I suspect if SrcPath was not defined the other 30 or so games would also have failed.

SrcPath is J:\PostInstall\Corey, see below...

Code: Select all

SET SRC=%CD:~0,2%
set SrcPath=%SRC%\PostInstall\%USERNAME%
set RegPath=%SRC%\PostInstall\%USERNAME%\Applications
I've run it dozens of times and it is null every single time. As I said - For this game and no other, regardless of where the entry is located within folders.txt.

From the log file

Code: Select all

17:00:27.39 Checking for Runescape 
17:00:27.39 NULL path returned for Runescape 
Which is written by....

Code: Select all

Echo %time% Checking for Runescape >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do IF /I "%%a"=="Runescape" set GamePath=%%b
IF "%GamePath%"=="" Echo NULL path returned for Runescape
IF "%GamePath%"=="" Echo %time% NULL path returned for Runescape >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
For example, here is the log output for Valorant yesterday...

Code: Select all

17:05:10.97 Checking for Valorant 
17:05:10.99 Valorant folder exists at D:\Program Files (x86)\Valorant. Overwriting. 
Really annoying that you can't reproduce the error. So I added output of paths to script. It now looks like...

Code: Select all

IF "%GamePath%"=="" (
	Echo NULL path returned for Runescape
	Echo %time% NULL path returned for Runescape >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
	Echo %time% SrcPath is  %SrcPath% >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
	IF EXIST "%SrcPath%\" Echo %time% Source path exists >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
	IF EXIST "%SrcPath%\Folders.txt" Echo %time% Folders.txt exists >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
)
and output is now

Code: Select all

16:22:09.37 NULL Path returned for Runescape
16:22:09.37 SrcPath is J:\PostInstall\Corey
16:22.09:37 Source path exists
16:22.09:39 Folders.txt exists

Re: command retunrs no value even though entry exists

Posted: 11 Sep 2020 03:12
by OJBakker
Is seems there is something in you Folders.txt that is not visible in the lines you have posted.
You need to examine what is going on inside the for-loop to see why it fails on Runescape.
Add the following code to yout batchfile, run it and check the new file FolderDEBUG.txt

Code: Select all

"%SrcPath%\foldersDEBUG.txt" ( for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do @echo "compare [%%a] to [Runescape] path [%%b]")

Re: command retunrs no value even though entry exists

Posted: 11 Sep 2020 05:27
by miskox
Would it be possible if there is no CRLF at the end (after the last line) that it would fail (I tested it and it works even without CRLF at the end.).?

Saso

Re: command retunrs no value even though entry exists

Posted: 13 Sep 2020 04:17
by Yanta
OJBakker wrote:
11 Sep 2020 03:12
Is seems there is something in you Folders.txt that is not visible in the lines you have posted.
You need to examine what is going on inside the for-loop to see why it fails on Runescape.
Add the following code to yout batchfile, run it and check the new file FolderDEBUG.txt

Code: Select all

"%SrcPath%\foldersDEBUG.txt" ( for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do @echo "compare [%%a] to [Runescape] path [%%b]")
Hey, thanks for that This is what is output...

Code: Select all

"compare [Runescape] to [Runescape] path [D:\Program Files\Jagex\RuneScape Launcher]"
Damn That looks like it got the path.

Ran

Code: Select all

for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do IF /I "%%a"=="Runescape" set GamePath=%%b
and it went back to null.

So I deleted the entire file and recreated it from scratch, 20 minutes later tried again and it seems to be working.... Go figure. The compare didn't pick anything up, but there must have been something dodgy with that line?

Re: command retunrs no value even though entry exists

Posted: 13 Sep 2020 05:10
by penpen
I suspect you initially used a code block (encapsulated in parentheses):

Code: Select all

(
Echo Checking for Runescape
for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do IF /I "%%a"=="Runescape" set GamePath=%%b
IF "%GamePath%"=="" Echo Empty path returned for Runescape
)

Re: command retunrs no value even though entry exists

Posted: 14 Sep 2020 04:32
by Yanta
I still am..

Code: Select all

IF /I "%DoGame:~0,1%"=="Y" (
Game 1
Game 2
Runescape
Game 3
Game 4
etc
)
I compared the folders.old.txt with the new one I created and there was 1 byte difference in the file size, but they looked identical. (3610 vs 3609 bytes)

Re: command retunrs no value even though entry exists

Posted: 14 Sep 2020 04:47
by miskox
It would be great to see binary compare. Probably your string 'Runescape' had an extra space or somethig.

Saso

Re: command retunrs no value even though entry exists

Posted: 14 Sep 2020 09:37
by penpen
Yanta wrote:
14 Sep 2020 04:32
I still am..
If your old and new code both work from inside a compound statement and your old code doesn't work, but your new one does then i suspect your new code to use delayed expansion (!variable!), contrary to your old code where you used regular expansion (%variable%).

Re: command retunrs no value even though entry exists

Posted: 17 Sep 2020 04:05
by Yanta
No, no, I didn't re-write any code at all.

When I said I "So I deleted the entire file and recreated it from scratch" I meant I recreated the folders.txt file.

There is no old code vs new code. The same code worked after recreating the folders.txt file, imho, reinforcing the earlier statement @ojbakker made 'There must be something invisible in the line..."

dir *. /s/b >folders.txt, then deleted all of the duplicate lines leaving only the parent folder for each game.

I don't use !variable! anywhere and delayed expansion is not enabled

Re: command retunrs no value even though entry exists

Posted: 17 Sep 2020 12:35
by penpen
The thing is, that a codeblock like the one i suspected above (and that you confirmed to use) can't work:

Code: Select all

(
Echo Checking for Runescape
for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do IF /I "%%a"=="Runescape" set GamePath=%%b
IF "%GamePath%"=="" Echo Empty path returned for Runescape
)
The reason is, that you can't access the actual content of an environment variable from within a compound statement using default (percentage) expansion. You only can access the value it had at the beginning of the compound statement.
If you want to access the actual content of a variable from within an compund statement, then you need to use delayed expansion; example:

Code: Select all

@echo off
set "var="
(
	set "var=value"

	if "%var%" == ""  echo %%var%% is empty
	echo %%var%%=%var%.

	setlocal enableDelayedExpansion
	if "!var!" == ""  echo ^^^!var^^^! is empty
	echo ^^^!var^^^!=!var!.
	endlocal
)
echo var=%var%
goto :eof
So it's confusing to hear that you are using a single compound statement for all games. Neither should work, if that's the code you have used.
(I initially suspected you have used the compound statement only for the game Runescape... .)


penpen

Re: command returns no value even though entry exists

Posted: 17 Sep 2020 19:56
by Yanta
Here is what it looks like. There are over 120 games so I won't post the entire games section..
When I said I "Created the file fron scratch" not one line of this code was changed. I recreated the folders.txt file from scratch.
The only changes I've made recently are to add .exe to the end of those that did not have it, which I did yesterday based on other feedback.

Code: Select all

 IF /I "%DoGame:~0,1%"=="Y" (
        Echo Installing and Configuring Games
        Echo %time% Installing games and settings >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        IF /I NOT "%USERNAME%"=="Peyton" IF /I NOT "%USERNAME%"=="Corey" IF /I NOT "%USERNAME%"=="Corey-Kodi" IF /I NOT "%USERNAME%"=="Bedroom" (
            IF EXIST "%SRC%\PostInstall\W7GW10.exe" (
                Echo %time% Installing Windows 7 Games for Windows 10 >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
                Start /wait "Windows 7 Games" /d "%SRC%\PostInstall\" "W7GW10.exe"
            )
        )
        
        IF EXIST "%PROGRAMFILES%\Microsoft Games\" (
            REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\freecell.exe" /v NoStartPage /d 1 /t REG_DWORD /f >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\solitaire.exe" /v NoStartPage /d 1 /t REG_DWORD /f >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\mahjong.exe" /v NoStartPage /d 1 /t REG_DWORD /f >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\Hearts.exe" /v NoStartPage /d 1 /t REG_DWORD /f >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Applications\spidersolitaire.exe" /v NoStartPage /d 1 /t REG_DWORD /f >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        )
        
Rem     BOS high scores
        Set GamePath=
        Echo %time% Checking for Balls of steel >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do IF /I "%%a"=="Balls of Steel" set GamePath=%%b
        IF EXIST "%GamePath%\" IF NOT "%GamePath%"=="" IF EXIST "%RegPath%\bos.reg" (
            Echo %time% Balls of Steel >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            REG IMPORT "%RegPath%\bos.reg" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        )
        
Rem     Hoyle Card games (2004)
        IF EXIST "%SrcPath%\Hoyle\" (
            Echo %time% Hoyle card games >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            xcopy "%SrcPath%\Hoyle\*.*" "%APPDATA%\Hoyle" /e/q/y/c/k/i/h >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        )
        
Rem     PopCap games
        IF EXIST "%SrcPath%\PDPopCap Games\" (
            Echo %time% PopCap games >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            xcopy "%SrcPath%\PDPopCap Games" "%PROGRAMDATA%\PopCap Games" /e/q/y/c/k/i/h/x >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        )
        
        IF EXIST "%SrcPath%\LAPopCap Games\" (
            Echo %time% Local APPData PopCap games >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            xcopy "%SrcPath%\LAPopCap Games" "%LOCALAPPDATA%\PopCap Games" /e/q/y/c/k/i/h/x >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        )
        IF EXIST "%RegPath%\Peggle.reg" REG IMPORT "%RegPath%\Peggle.reg" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        IF EXIST "%RegPath%\Bejeweled3.reg" REG IMPORT "%RegPath%\Bejeweled3.reg" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        
Rem     Misc games      
        IF EXIST "%SrcPath%\Saved Games\" (
            Echo %time% Saved games folder >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            xcopy "%SrcPath%\Saved Games" "%USERPROFILE%\Saved Games" /e/q/y/c/k/i/h/x >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        )

Rem     Microsoft Games folder Some games go in local Eg W7G4W10, some go in roaming Eg Rise of nations
        IF EXIST "%SrcPath%\AD Microsoft Games\" (
            Echo %time% APPData Microsoft games >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            xcopy "%SrcPath%\AD Microsoft Games" "%APPDATA%\Microsoft Games" /e/q/y/c/k/i/h/x >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        )
        
        IF EXIST "%SrcPath%\Microsoft Games\" (
            Echo %time% Local APPData Microsoft games >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            xcopy "%SrcPath%\Microsoft Games" "%LOCALAPPDATA%\Microsoft Games" /e/q/y/c/k/i/h/x >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        )
        
Rem     Max Payne 2
        Set GamePath=
        Set D2Test=
        for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do IF /I "%%a"=="Max payne 2" set GamePath=%%b
        IF NOT "%GamePath%"=="" IF EXIST "%GamePath%\" IF EXIST "%SrcPath%\MaxPayne2\" IF EXIST "%RegPath%\MaxPayn2.reg" (
            Echo %time% Checking for Max Payne 2 Save games  >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            REG IMPORT "%RegPath%\MaxPayne2.reg" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            FOR /f "tokens=5*" %%a in ('REG QUERY "HKEY_CURRENT_USER\Software\Remedy Entertainment\Max Payne 2\Save Game" /v "Last Saved Game Filename"') do set D2Test=%%~dpb
            set D2Test=%D2Test:\\=\%
            IF NOT "%D2Test%"=="" IF NOT EXIST "%D2Test%\" xcopy "%SrcPath%\MaxPayne2" "%D2Test%" /e/q/y/c/k/i/h/x >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        )

Rem     Runescape.
        Set GamePath=
        Echo %time% Checking for Runescape >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do IF /I "%%a"=="Runescape" set GamePath=%%b
        IF "%GamePath%"=="" Echo NULL path returned for Runescape
        IF "%GamePath%"=="" Echo %time% NULL path returned for Runescape >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        IF EXIST "%GamePath%\" Echo %time% Runescape already installed >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        IF NOT EXIST "%GamePath%\" IF NOT "%GamePath%"=="" EXIST "%SrcPath%\RuneScape-Setup.exe" (
            Echo Installing RuneScape. Make sure to install on "%GamePath%"
            Echo %time% Installing RuneScape >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            "%SrcPath%\RuneScape-Setup.exe"
        )
        IF EXIST "%RegPath%\Runescape.reg" REG IMPORT "%RegPath%\Runescape.reg" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        
        IF EXIST "%SrcPath%\Alt1Setup.exe" (
            Echo Installing ALT1 Toolkit
            Echo %time% Installing Alt1 Toolkit >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            "%SrcPath%\Alt1Setup.exe" /s
            IF EXIST "%SrcPath%\Alt1Toolkit\" (
                Echo %time% Copying ALT1 local files >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
                xcopy "%SrcPath%\Alt1Toolkit" "%LOCALAPPDATA%\Alt1Toolkit" /e/q/y/c/k/i/h/x >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            )
        )
    
Rem     Runescape settings
        IF EXIST "%SrcPath%\Jagex\" (
            xcopy "%SrcPath%\Jagex" "%LOCALAPPDATA%\Jagex" /e/q/y/c/k/i/h >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            IF EXIST "%RegPath%\jagex.reg" (
                REG IMPORT "%RegPath%\jagex.reg" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            )
        )
Rem     Runescape Java Cache
        IF EXIST "%SrcPath%\JagexCache\" (
            Echo %time% Copying Runescape Java Cache folder >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            xcopy "%SrcPath%\JagexCache" "%USERPROFILE%\JagexCache" /e/q/y/c/k/i/h >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            IF EXIST "%SrcPath%\jagex_cl_runescape_LIVE.dat" (
                copy "%SrcPath%\jagex_cl_runescape_LIVE.dat" "%USERPROFILE%" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            )
	 IF EXIST "%SrcPath%\jagex_cl_oldschool_LIVE.dat" (
                copy "%SrcPath%\jagex_cl_oldschool_LIVE.dat" "%USERPROFILE%" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            )
            IF EXIST "%SrcPath%\jagexappletviewer.preferences" (
                copy "%SrcPath%\jagexappletviewer.preferences" "%USERPROFILE%" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            )

        )
Rem     NXT Cache 27/07/2020        
        IF EXIST "%SrcPath%\PDJagex\" (
            Echo %time% Copying Runescape NXT cache >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            xcopy "%SrcPath%\PDJagex" "%PROGRAMDATA%\Jagex" /e/q/y/c/k/i/h >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
        )
        
Rem     Minecraft
        Set GamePath=
        for /F "Usebackq Tokens=1* delims=," %%a in ("%SrcPath%\folders.txt") do IF /I "%%a"=="Minecraft" set GamePath=%%b
        IF NOT "%GamePath%"=="" IF EXIST "%GamePath%\MinecraftLauncher.exe" (
            Echo %time% Copying minecraft config files >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            IF EXIST "%RegPath%\minecraft.reg" (
                REG IMPORT "%RegPath%\minecraft.reg" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            )
            IF EXIST "%SrcPath%\.Minecraft\" (
                xcopy "%SrcPath%\.Minecraft" "%APPDATA%\.Minecraft" /e/q/y/c/k/i/h >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
            )
        )
        Rem 	Golf Around
		Set GamePath=
		Echo %time% Checking for Golf Around >>C:\%USERDOMAIN%.Backup.Log 2>&1
		for /F "Usebackq Tokens=1* delims=," %%a in ("%UserPath%\folders.txt") do IF /I "%%a"=="Golf Around" set GamePath=%%b
		Echo %time% Path: '%GamePath%' >>C:\%USERDOMAIN%.Backup.Log 2>&1
		IF EXIST "%GamePath%\" IF NOT "%GamePath%"=="" (
			REG IMPORT "%RegPath%\GolfAround.reg" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
		)

Rem 	Fall Guys
		Set GamePath=
		Echo %time% Checking for Fall Guys >>C:\%USERDOMAIN%.Backup.Log 2>&1
		for /F "Usebackq Tokens=1* delims=," %%a in ("%UserPath%\folders.txt") do IF /I "%%a"=="Fall Guys" set GamePath=%%b
		Echo %time% Path: '%GamePath%' >>C:\%USERDOMAIN%.Backup.Log 2>&1
		IF EXIST "%GamePath%\" IF NOT "%GamePath%"=="" (
			REG IMPORT "%RegPath%\FallGuys.reg" >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
		)
Rem 	Ninja Kiwi Archive
		Set GamePath=
		Echo %time% Checking for Ninja Kiwi Archive >>C:\%USERDOMAIN%.Backup.Log 2>&1
		for /F "Usebackq Tokens=1* delims=," %%a in ("%UserPath%\folders.txt") do IF /I "%%a"=="Ninja Kiwi" set GamePath=%%b
		Echo %time% Path: '%GamePath%' >>C:\%USERDOMAIN%.Backup.Log 2>&1
		IF EXIST "%GamePath%\" IF NOT "%GamePath%"=="" (
			REG IMPORT "%RegPath%\NinjaKiwi.reg" >>C:\%USERDOMAIN%.Backup.Log 2>&1
		)

Rem 	7 Days to Die
		Set GamePath=
		Echo %time% Checking for 7 Days to Die >>C:\%USERDOMAIN%.Backup.Log 2>&1
		for /F "Usebackq Tokens=1* delims=," %%a in ("%UserPath%\folders.txt") do IF /I "%%a"=="7 Days to die" set GamePath=%%b
		Echo %time% Path: '%GamePath%' >>C:\%USERDOMAIN%.Backup.Log 2>&1
		IF EXIST "%GamePath%\" IF NOT "%GamePath%"=="" (
			REG IMPORT "%RegPath%\7Daystodie.reg" >>C:\%USERDOMAIN%.Backup.Log 2>&1
			IF EXIST "%SrcPath%\RA7Daystodie\" xcopy "%SrcPath%\RA7daystodie" "%APPDATA%\7Daystodie" /e/q/y/c/k/i/h >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
		)
		
Rem 	Knight Online
		Set GamePath=
		Echo %time% Checking for Knight Online >>C:\%USERDOMAIN%.Backup.Log 2>&1
		for /F "Usebackq Tokens=1* delims=," %%a in ("%UserPath%\folders.txt") do IF /I "%%a"=="Knight Online" set GamePath=%%b
		Echo %time% Path: '%GamePath%' >>C:\%USERDOMAIN%.Backup.Log 2>&1
		IF EXIST "%GamePath%\" IF NOT "%GamePath%"=="" (
			REG IMPORT "%RegPath%\KnightOnline.reg" >>C:\%USERDOMAIN%.Backup.Log 2>&1
		)	
		
Rem 	Dota 2 beta
		Set GamePath=
		Echo %time% Checking for Dota 2 beta >>C:\%USERDOMAIN%.Backup.Log 2>&1
		for /F "Usebackq Tokens=1* delims=," %%a in ("%UserPath%\folders.txt") do IF /I "%%a"=="Dota 2 beta" set GamePath=%%b
		Echo %time% Path: '%GamePath%' >>C:\%USERDOMAIN%.Backup.Log 2>&1
		IF EXIST "%GamePath%\" IF NOT "%GamePath%"=="" (
			REG IMPORT "%RegPath%\KnightOnline.reg" >>C:\%USERDOMAIN%.Backup.Log 2>&1
		)
	)
	

Re: command retunrs no value even though entry exists

Posted: 18 Sep 2020 05:48
by penpen
Only flying over your source (i actually have few time, sorry).

I assume that prior to the if command the environment variable GamePath is undefined; you might want to check that by adding:

Code: Select all

echo("GamePath=%GamePath%"

IF /I "%DoGame:~0,1%"=="Y" (
:: ...
)

Based on that Gamepath is undefined:
Some of your routines seem to work well, because it seems they don't use variables defined within the compound-statement (for example sections "Hoyle Card games (2004)", "PopCap games", ...), while all that do (for example use GamePath) shouldn't work correct, because of the above mentioned reason (for example sections "BOS high scores", "Max Payne 2", "Runescape" ...).


penpen

Re: command retunrs no value even though entry exists

Posted: 18 Sep 2020 11:05
by Compo
The same variable expansion issue you have with `GamePath` is also evident in your 'Max Payne 2' section, with `D2Test`