Rotornut44
Resource contributor
- Messages
- 658
- Country
[SOLVED]
Hello,
I know enough batch script to get me by in most cases, but lately I've had to start pulling information from the registry. My current knowledge of scripting just doesn't seem to suffice anymore.
A few weeks ago, I pieced together the following bit of code to check the version (if there is a version) of SODE installed on a users computer. So far it seems to be working flawlessly.
setlocal
set CheckVersion=1.5.1
for /f "tokens=3" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\12bPilot\SimObject Display Engine" /v Version ^| find /i "Version"') do set Version=%%a
if "%Version%"=="%CheckVersion%" (
goto movefiles
)
Today, I have attempted to use some of this code to pull a registry value for P3Dv4 in order to activate an Object Library after running it's installer. A snippet of the script follows:
reg query HKLM\Hardware\Description\System\CentralProcessor\0 | find /i "x86" > nul
if %errorlevel% == 1 goto systemx64
:systemx86
for /f "tokens=3" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Lockheed Martin\Prepar3D v4" /v SetupPath ^| find /i "SetupPath"') do set p3dPath=%%a
goto checkpath
:systemx64
for /f "tokens=3" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Lockheed Martin\Prepar3D v4" /v SetupPath ^| find /i "SetupPath"') do set p3dPath=%%a
:checkpath
if not exist "%p3dPath%Prepar3D.exe" goto abort
"%p3dPath%Prepar3D.exe" "-Configure: File=Scenery, Operation=Add, Path=Emerald Scenery Design/EOLv2, Title=EOLv2, Required=False, Active=True"
The script works as it should up until it jumps to :systemx64. From there it tells me that the system cannot find the specified registry key or value.
Any ideas? My best guess is that I'm doing something that the for command doesn't like. This is being tested under Windows 10.
Edit: I have also tried "tokens=1-2*" (This part is a bit confusing for me atm)
Hello,
I know enough batch script to get me by in most cases, but lately I've had to start pulling information from the registry. My current knowledge of scripting just doesn't seem to suffice anymore.
A few weeks ago, I pieced together the following bit of code to check the version (if there is a version) of SODE installed on a users computer. So far it seems to be working flawlessly.
setlocal
set CheckVersion=1.5.1
for /f "tokens=3" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\12bPilot\SimObject Display Engine" /v Version ^| find /i "Version"') do set Version=%%a
if "%Version%"=="%CheckVersion%" (
goto movefiles
)
Today, I have attempted to use some of this code to pull a registry value for P3Dv4 in order to activate an Object Library after running it's installer. A snippet of the script follows:
reg query HKLM\Hardware\Description\System\CentralProcessor\0 | find /i "x86" > nul
if %errorlevel% == 1 goto systemx64
:systemx86
for /f "tokens=3" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Lockheed Martin\Prepar3D v4" /v SetupPath ^| find /i "SetupPath"') do set p3dPath=%%a
goto checkpath
:systemx64
for /f "tokens=3" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Lockheed Martin\Prepar3D v4" /v SetupPath ^| find /i "SetupPath"') do set p3dPath=%%a
:checkpath
if not exist "%p3dPath%Prepar3D.exe" goto abort
"%p3dPath%Prepar3D.exe" "-Configure: File=Scenery, Operation=Add, Path=Emerald Scenery Design/EOLv2, Title=EOLv2, Required=False, Active=True"
The script works as it should up until it jumps to :systemx64. From there it tells me that the system cannot find the specified registry key or value.
Any ideas? My best guess is that I'm doing something that the for command doesn't like. This is being tested under Windows 10.
Edit: I have also tried "tokens=1-2*" (This part is a bit confusing for me atm)
Last edited: