[FS2002/FS2004/FSX/FSXA] Scenery-Auto-Adder (SAA) test

#2
Hello emshomar,

This is exactly what I need to do. However, when I run the batch script, I get this:
Code:
ERROR: The system was unable to find the specified registry key or value.
'INIMOD' is not recognized as an internal or external command,
operable program or batch file.
Layer=1
...
Layer=119
Layer=120

---------- SCENERY.CFG
[Area.099]
[Area.100]
[Area.101]
[Area.102]
[Area.103]
[Area.104]
[Area.105]
[Area.106]
[Area.107]
[Area.108]
[Area.109]
[Area.110]
[Area.111]
[Area.112]
[Area.113]
[Area.114]
[Area.115]
[Area.116]
[Area.117]
[Area.118]
[Area.119]
[Area.120]
The operation completed successfully.
'INIMOD' is not recognized as an internal or external command,
operable program or batch file.
'INIMOD' is not recognized as an internal or external command,
operable program or batch file.
'INIMOD' is not recognized as an internal or external command,
operable program or batch file.
'INIMOD' is not recognized as an internal or external command,
operable program or batch file.
'INIMOD' is not recognized as an internal or external command,
operable program or batch file.
'INIMOD' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .
I have not seen, nor worked with the INIMOD, but I am guessing that it is some required library on the installing machine? Any ideas?
 
Last edited:
#3
I have not seen, nor worked with the INIMOD, but I am guessing that it is some required library on the installing machine? Any ideas?
See the script was looking for the next available Area and Layer Number.

Your next available number should be 121 or 120 I guess.

So to write into the based INI file you need a external batch module, which is INIMod. You can get it in my example file or google it.
 
Last edited:
#4
Hello emshomar,

Thanks for the reply. I figured out what the script was doing. Using your code, I modified it a bit, and got this working on the install:
Code:
:WRTZ
REG ADD "HKLM\SOFTWARE\Name of Scenery" /v SceneryIndex /t REG_SZ /d 0%VAR%
ECHO.[Area.%VAR%] >>scenery.cfg
ECHO.Title "Name of Scenery" >>scenery.cfg
ECHO.Layer %LAY% >>scenery.cfg
ECHO.Active True >>scenery.cfg
ECHO.Required FALSE >>scenery.cfg
ECHO.Local "Addon Scenery\Name of Scenery" >>scenery.cfg
ECHO.Remote " " >>scenery.cfg
GOTO END

:WRTH
REG ADD "HKLM\SOFTWARE\Name of Scenery" /v SceneryIndex /t REG_SZ /d %VAR%
ECHO.[Area.%VAR%] >>scenery.cfg
ECHO.Title "Name of Scenery" >>scenery.cfg
ECHO.Layer %LAY% >>scenery.cfg
ECHO.Active True >>scenery.cfg
ECHO.Required FALSE >>scenery.cfg
ECHO.Local "Addon Scenery\Name of Scenery" >>scenery.cfg
ECHO.Remote " " >>scenery.cfg
GOTO END
But am having a hard time getting the uninstall to grab the whole entry. I will check out the INIMod. Thanks for your contribution! By the way, I am using this on Windows 7 64-Bit Ultimate.

Also, Windows Vista/7( Win V/7 ) saves the 'All Users' information to the "C:\ProgramData\Microsoft\FSX\scenery.cfg" file, while XP saves it in "C:\Documents and Settings\All Users\Application Data\Microsoft\FSX\scenery.cfg".

I have tested several scenarios between XP and V/7( Win V/7 has a "C:\Documents and Settings\All Users\Application Data\Microsoft\FSX\scenery.cfg" path and file, it is just hidden ). If you ECHO out where the paths are going, you can see if it is installing for XP or Win V/7.

I will report back! Thanks again! ;)
 
#6
Ok!...

Hello emshomar! :wave:

I couldn't get your script to work, so I had to modify it. So now I have a working Batch script for Automatically adding and removing addon scenery. This should work on Windows XP, Vista and 7, 32 and 64 bit systems, as it reads the install path of FSX from the registry. It also then determines which Operating system you are using, by checking to see if certain folders EXIST; if not it defaults to Windows XP.

Based off of your original Batch Script, I have made it so that 'extra' libraries, programs and what-nots are not needed.

When the script is run, it gives the user a choice to either let the script automatically add the scenery to the library or exit; so they can add it manually, should they choose.

I have tested this for that last couple days on my computer, and haven't had any 'weirdness', but I have to say:
USE THIS AT YOUR OWN RISK! I CANNOT AND WILL NOT BE RESPONSIBLE FOR ANYTHING UNEXPECTED FOR ANY REASON! THIS IS BETA CODE, AND AS SUCH, MAY HAVE UNDESIRED RESULTS!

BATCH FOR ADDING SCENERY:
Code:
@ECHO off

:START
CLS
SET /p userinp=Would you like [COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR] added to your scenery library automatically( 1 = Yes, 2 = No )?
SET userinp=%userinp:~0,1%
IF "%userinp%"=="1" GOTO SETUP
IF "%userinp%"=="2" GOTO EXIT
ECHO Invalid Selection
GOTO START

:SETUP

SET WINV7_PATH="C:\ProgramData\Microsoft\FSX"
SET WINXP_PATH="C:\Documents and Settings\All Users\Application Data\Microsoft\FSX"
SET FSX_PATH=""

:: Check to see which Operating System the User is using...
IF EXIST %WINV7_PATH% (
	:: set the correct path for the USER SCENERY.CFG for Windows Vista/7
	SET FSX_PATH=%WINV7_PATH%
) ELSE (
	:: otherwise, set the correct path for the USER SCENERY.CFG for Windows XP
	SET FSX_PATH=%WINXP_PATH%
)

:: Change to the directory where the USER SCENERY.CFG file is located.
CD %FSX_PATH%

:: Start emshomar's routine for iterating through the entries
SET /A LAY=1

:LAY
FINDSTR /C:"Layer=%LAY%" scenery.cfg
IF ERRORLEVEL 1 GOTO PH1
IF NOT ERRORLEVEL 1 SET /A LAY=%LAY%+1
GOTO LAY

:PH1
FIND /I "[Area.099]" scenery.cfg
IF ERRORLEVEL 1 GOTO Z
IF NOT ERRORLEVEL 1 GOTO H

:Z
SET /A VAR=10
:CHKZ
FINDSTR /C:"[Area.0%VAR%]" scenery.cfg
IF ERRORLEVEL 1 GOTO WRTZ
IF NOT ERRORLEVEL 1 SET /A VAR=%VAR%+1
GOTO CHKZ

:H
SET /A VAR=100
:CHKH
FINDSTR /C:"[Area.%VAR%]" scenery.cfg
IF ERRORLEVEL 1 GOTO WRTH
IF NOT ERRORLEVEL 1 SET /A VAR=%VAR%+1
GOTO CHKH

:: Changed how the file entry is written in WRTZ and WRTH
:: Adds second Registry Entry for scenery.cfg location - For uninstall
:WRTZ
REG ADD "HKLM\SOFTWARE\[COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR]" /v SceneryIndex /t REG_SZ /d 0%VAR%
REG ADD "HKLM\SOFTWARE\[COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR]" /v SceneryCFGPath /t REG_SZ /d %FSX_PATH%
ECHO.>>scenery.cfg
ECHO.[Area.%VAR%]>>scenery.cfg
ECHO.Title="[COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR]">>scenery.cfg
ECHO.Layer=%LAY%>>scenery.cfg
ECHO.Active=True>>scenery.cfg
ECHO.Required=FALSE>>scenery.cfg
ECHO.Local="Addon Scenery\[COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR]">>scenery.cfg
GOTO END

:WRTH
REG ADD "HKLM\SOFTWARE\[COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR]" /v SceneryIndex /t REG_SZ /d %VAR%
REG ADD "HKLM\SOFTWARE\[COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR]" /v SceneryCFGPath /t REG_SZ /d %FSX_PATH%
ECHO.>>scenery.cfg
ECHO.[Area.%VAR%]>>scenery.cfg
ECHO.Title="[COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR]">>scenery.cfg
ECHO.Layer=%LAY%>>scenery.cfg
ECHO.Active=True>>scenery.cfg
ECHO.Required=FALSE>>scenery.cfg
ECHO.Local="Addon Scenery\[COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR]">>scenery.cfg
GOTO END

:END
ECHO Successfully added [COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR] to your scenery.cfg file!
PAUSE
EXIT

:EXIT
ECHO DON'T FORGET TO MANUALLY ADD [COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR] TO YOUR SCENERY LIBRARY!
PAUSE
EXIT
The Batch file for removing the scenery, was considerably tougher! :yikes: I had to seek expert advice, and dbenham, over at stackoverflow.com, was kind enough to give me a hand.

BATCH FOR REMOVING SCENERY
Code:
@ECHO off
SETLOCAL disableDelayedExpansion
SET regPath="HKLM\SOFTWARE\[COLOR="DarkRed"][b]YOUR_SCENERY[/b][/COLOR]"

SET "myPath="
FOR /f "tokens=3 skip=2" %%A IN ('reg query %regPath% /v SceneryCFGPath') DO SET "myPath=%%A"
IF NOT DEFINED myPath CALL :ERROR Unable to locate SceneryCFGPath
cd /d "%myPath%" 2>nul || CALL :ERROR Unable to CD to "%myPath%"

SET "area="
FOR /f "tokens=3 skip=2" %%A IN ('reg query %regPath% /v SceneryINdex') DO SET "area=%%A"
IF NOT DEFINED area CALL :ERROR Unable to unregister from Scenery Library ! Please delete the Area manually...

SET "beginDel="
FOR /f "delims=:" %%N IN ('FINDSTR /nbc:"[Area.%area%]" scenery.cfg') DO SET beginDel=%%N
IF NOT DEFINED beginDel GOTO END

SET "endDel="
FOR /f "delims=:" %%N IN ('FINDSTR /nbc:"[Area." scenery.cfg') DO IF %%N gtr beginDel (
  SET ENDCond=IF %%A gre %%N
  GOTO :BREAK
)
:BREAK

>scenery.cfg.new (
  FOR /f "tokens=1* delims=:" %%A IN ('FINDSTR /n "^" scenery.cfg') DO (
    IF %%A lss %beginDel% %ENDCond% ECHO(%%B
  )
)
MOVE /y scenery.cfg.new scenery.cfg

reg delete %regPath% /f
GOTO END

:ERROR
ECHO ERROR: %*
PAUSE

:END
ECHO FINISHED!
PAUSE
I have only tested this on my system, but it DOES WORK. If someone with Windows XP could verify; or better yet, someone with Windows XP AND FSX installed outside default locations and report back, that would be great! ;)

Thanks to emshomar and dbenham for the start and finish! :wave:
 
Last edited:
#7
Sorry for my late response, since I am still 15 I had to do a lot for school.
That the scenery.cfg file is somewhere else on XP I didn't know! It's great to hear that someone else helped my investigation about how to make the uninstaller even working without 3rd party module. I think with your new modded script should fix also some serious bugs I had bevore! I will test that in the near future. Thx!
 
#8
Sven2157,

Thank you 500 million times!! :D:D:D:D

You have shown me things with bat files that I have forgotten about! :teacher:

Adapting this script for Prepar3D is a matter of changing the location of the scenery.cfg file!

Thanks again for sharing! :wave:
 
#9
Guys,

I need to strain someone's brain here... :)

I have adapted the script for Prepar3D and it can add the scenery, but it cannot remove it...

The path to the Prepar3D scenery.cfg file is here:
Windows 7 : C:\ProgramData\Lockheed Martin\Prepar3D
Windows XP: C:\Documents and Settings\All Users\Application Data\Lockheed Martin\Prepar3D

Notice the SPACE between the LOCKHEED MARTIN. This is what is throwing the remover off because I get an error like this.

ERROR: Unable to CD to "C:\ProgramData\Lockheed"

I know there is a way to compensate for the space. The problem is in this line:

FOR /f "tokens=3 skip=2" %%A IN ('reg query %regPath% /v SceneryCFGPath') DO SET "myPath=%%A"

The %%A variable cannot handle the space in the path...

If someone can help, then please do. I will keep on looking myself and post my findings in here.

Regards,
 
Last edited:
#10
Guys,

I need to strain someone's brain here... :)

I have adapted the script for Prepar3D and it can add the scenery, but it cannot remove it...

The path to the Prepar3D scenery.cfg file is here:
Windows 7 : C:\ProgramData\Lockheed Martin\Prepar3D
Windows XP: C:\Documents and Settings\All Users\Application Data\Lockheed Martin\Prepar3D

Notice the SPACE between the LOCKHEED MARTIN. This is what is throwing the remover off because I get an error like this.

ERROR: Unable to CD to "C:\ProgramData\Lockheed"

I know there is a way to compensate for the space. The problem is in this line:

FOR /f "tokens=3 skip=2" %%A IN ('reg query %regPath% /v SceneryCFGPath') DO SET "myPath=%%A"

The %%A variable cannot handle the space in the path...

If someone can help, then please do. I will keep on looking myself and post my findings in here.

Regards,
Try to change %%A to %%I
 
#13
What code is this? Looks very familiar. Havent done programming in 10 years - where did time go?
DOS : Disk Operating System! :teacher:

It is the stuff computers worked on before Windows! :D

Back in the day you had to learn all this if you wanted to operate a computer! Naturally you had a lot more clever computer operators back then. People who actually knew more than just where to switch the thing on! :duck:
 
#15
It seems that progrmming with Batch seems to be very unstable! One of my mashines can't remove, because FOR /A commands don't probably work:confused:. I can not programm EXE! The only thing that I can create is to convert my batch script to EXE, but it stays the same with same bug, errors, etc.:(
 
#16
It seems that progrmming with Batch seems to be very unstable! One of my mashines can't remove, because FOR /A commands don't probably work:confused:. I can not programm EXE! The only thing that I can create is to convert my batch script to EXE, but it stays the same with same bug, errors, etc.:(
You can do Basic or Z-Basic.

I remember the DOS system and similarities to RedHat.
Wouldnt take me long to pick it back up. Kow any good tutorials where I can re-insert my floppy for programming?
 
#18
I have an application ready in Visual Basic.net.

What does it do?
- Make a backup of the scenery.cfg before adding something
- Adds your scenery layer
- Saves the new scenery.cfg
- Make a backup of the scenery.cfg before deleting something
- Deletes your scenery layer
- Saves the new scenery.cfg again

Until now it did not give me any errors, seems like it works like a charm... (hopefully)

If there is somebody interested in, I am willing to share, but I do not want to post it here as I am not a pro in developing and my "way" to code is simple, but I will share it for everyone who wants it. Either drop me a PM or a mail and I'll send you the VB.net working folder, or if you want that I finish the application directly, tell me!
 
#19
Folks, let's keep this on topic; This is, and was meant, as a BATCH file that an INSTALLER can run after installing scenery to a user's computer. C++ and VB are not viable, because of the possible need for outside logic.

Running Batch files is simple, quick and EVERY OS( XP, Vista and 7 ) has the cmd.exe -- just make sure that you use XP commands in your scripts, if you adjust it! Batch commands like CHOICE, are a Windows Vista/7 command ONLY!

Also, for those of you having trouble removing the scenery. Please note that on a 64 Bit OS, the Registry Entry could actually be written here:
Code:
HKEY_LOCAL_MACHINE\SOFTWARE\[b][color=darkred]Wow6432Node[/color][/b]\YOUR_PRODUCT
You may have to adjust this so that the Uninstaller.bat can find the correct values.
 
Last edited:
#20
...
Adapting this script for Prepar3D is a matter of changing the location of the scenery.cfg file!
...
...
The path to the Prepar3D scenery.cfg file is here:
Windows 7 : C:\ProgramData\Lockheed Martin\Prepar3D
Windows XP: C:\Documents and Settings\All Users\Application Data\Lockheed Martin\Prepar3D

Notice the SPACE between the LOCKHEED MARTIN. This is what is throwing the remover off because I get an error like this.
...
You should enclose that in double quotes ( " ). It should look like this:
Code:
"C:\ProgramData\Lockheed Martin\Prepar3D"
 
Top