VirtualStore Detector

Puppeteer

Emperor
Joined
Oct 4, 2003
Messages
1,687
Location
Silverdale, WA, USA
NOTICE: Please see my updated app Civ3 Explorer which does the same thing as this but is easier to use.
-----

I suspect quite a few problems reported with Civ3 on Vista/Win7/Win8 problems are due to VirtualStore. VirtalStore is difficult to explain, but perhaps it's easy to detect by script. The purpose of this file is to try to tell the user if they have Civ3 files in VirtualStore which may cause them issues.

Player/modder issues with VirtualStore include:
  • VirtualStore files may not go away after uninstall
  • Mod files in protected location and VirtualStore may be out of sync
  • Running Civ3 with different privileges (user, admin, compatibility) may cause different files to be used

This is my first release; I have only tested it on my PC, but all it does is read 3 registry keys and look at 3 folder locations. I would appreciate feedback on if/how it works and if it is helpful.

Download the version 0.5 file here:
civ3-virt-v0_5.bat
 
What it does:

  1. Checks if %LOCALAPPDATA%\VirtualStore exists
  2. Checks if 32-bit/64-bit OS because Civ3 registry location is different
  3. Reads installed location for Civ3, PTW and Conquests from the registry
  4. Guesses where VirtualStore folder for those locations would be
  5. Tells you if the VirtualStore folder location(s) exist for your Civ3 installs
  6. Waits for a keypress to exit the cmd window

Problems I hope it can help solve:
  • Save files "missing"
  • Mod files in unexpected places
  • VirtualStore mod files remaining after uninstall/reinstall

Things not yet known:
  • Do all distributions use the same reg key locations? (original CDs, Complete, Steam)
  • How gracefully this will exit if reg keys don't exist
  • If VirtualStore and installed folders are on different drive letters

Sample output:
Code:
VirtualStore folder detected at C:\Users\jim.AD\AppData\Local\VirtualStore

Detecting if we are running 32-bit, otherwise assume 64-bit:
64-bit

Reading install paths from registry...

Your CivIII install location:
c:\users\games\civ3
There is no VirtualStore detected for this folder.

Your PTW install location:
c:\users\games\civ3\Civ3PTW
There is no VirtualStore detected for this folder.

Your Conquests install location:
c:\users\games\civ3\Conquests
There is no VirtualStore detected for this folder.

Press any key to continue . . .

My Civ3 is not installed in a protected location, so I don't have any Civ3 files in VirtualStore. I haven't tested it on a PC that does yet.

If people find this useful I might think about how to make it more useful like somehow allowing you to browse to the folders and suggest potential problems such as save files or mod files in VirtualStore and the real location. Perhaps this should be an .hta application to be easier to use and allow extra functionality.
 
civ3-virt-v_05.bat contents:
Code:
@echo off

REM 2013-09-09 CivFanatics user Puppeteer
REM I suspect a lot of Civ3 on Vista/Win7/Win8 problems are due to VirtualStore.
REM VirtalStore is difficult to explain, but perhaps it's easy to script?
REM The purpose of this file is to try to tell the user if they have Civ3
REM files in VirtualStore which may cause them issues.

REM Issues Include:
REM		VirtualStore files may not go away after uninstall
REM		Mod files in protected location and VirtualStore may be out of sync
REM		Running Civ3 with different privileges (user, admin, compatibility) may cause different files to be used

REM	First, does VirtualStore exist on this user profile?
set VS=%LOCALAPPDATA%\VirtualStore
if not exist %VS%\NUL goto NOVIRTUALSTORE
echo VirtualStore folder detected at %VS%

REM Civ3 is 32-bit program; if on 64-bit OS the registry entries are in a different place
REM Let's figure out if we're on a 64-bit OS or 32-bit OS
REM Yoinked from http://stackoverflow.com/questions/4990839/batch-to-detect-if-system-is-a-32-bit-or-64-bit
REM In theory need to test for "if not defined %PROCESSOR_ARCHITEW6432%" but I can't figure out how to "and" an if statement and have the else without goto's
echo.
echo Detecting if we are running 32-bit, otherwise assume 64-bit:
set WOW6432=""
if %PROCESSOR_ARCHITECTURE%==x86 (
  rem 32 bit
  echo 32-bit
) else (
  rem 64 bit
  echo 64-bit
  set WOW6432=Wow6432Node\
)

REM Let's get the installed paths from the registry
REM Yoinked reg-query-to-variable method from http://stackoverflow.com/questions/10359001/how-to-read-a-reg-value-into-an-environment-variable
echo.
echo Reading install paths from registry...
for /f "tokens=2*" %%x in ('reg query "HKLM\Software\%WOW6432%Infogrames Interactive\Civilization III" /v Install_Path') do set CIV3=%%y
for /f "tokens=2*" %%x in ('reg query "HKLM\Software\%WOW6432%Infogrames\Civ3PTW" /v Install_Path') do set PTW=%%y
for /f "tokens=2*" %%x in ('reg query "HKLM\Software\%WOW6432%Infogrames\Conquests" /v Install_Path') do set C3C=%%y

REM Now let's assume VirtualStore paths
REM I don't know how VirtualStore works if %LOCALAPPDATA% and the installed path are different drive letters, but it's probably and edge case
REM The ~pn in the %%~pnx takes just the path and "file" name (in this case the folder) and omits the drive letter. I can't to this directly with an environment variable, so I'm using the "for" construct so I can use it on %%x
for %%x in ("%CIV3%") do set VSCIV3=%VS%%%~pnx
for %%x in ("%PTW%") do set VSPTW=%VS%%%~pnx
for %%x in ("%C3C%") do set VSC3C=%VS%%%~pnx

echo.
echo Your CivIII install location:
echo %CIV3%
if exist %VSCIV3%\NUL (
	echo There are VirtualStore files that may override this location at:
	echo %VSCIV3%
) else (
	echo There is no VirtualStore detected for this folder.
)

echo.
echo Your PTW install location:
echo %PTW%
if exist %VSPTW%\NUL (
	echo There are VirtualStore files that may override this location at:
	echo %VSPTW%
) else (
	echo There is no VirtualStore detected for this folder.
)

echo.
echo Your Conquests install location:
echo %C3C%
if exist %VSC3C%\NUL (
	echo There are VirtualStore files that may override this location at:
	echo %VSC3C%
) else (
	echo There is no VirtualStore detected for this folder.
)

goto END

:NOVIRTUALSTORE

echo.
echo VirtualStore folder not detected on your user profile
echo at %VS%
echo Exiting
goto END

:END

REM debug:
REM echo.
REM echo %VS%
REM echo %CIV3%
REM echo %PTW%
REM echo %C3C%
REM echo %VSCIV3%
REM echo %VSPTW%
REM echo %VSC3C%

echo.
pause
 
Back
Top Bottom