AwesomeMod Updater (v2.8.3 - Updated 2013-10-16)

<< < (54/61) > >>

basbas:
Quote from: Gigowatt on 2013 February 26, 11:34:27

You can increase your script compatibility by replacing each "wget" and "unzip" words by "%~dp0wget.exe" and "%~dp0unzip.exe".
"%~dp is the source path where the script is launched from (= where the script is placed).
So you can use CD command (I prefer PUSHD) as often as you want, "%~dp variable won't change ;)
Supported for all NT OS.

(I had to do this modification for me because wget and unzip were not recognized commands.)


Oh, that's interesting, thanks. I'll see what I'm going to do with that.

Do you have any idea why it didn't recognise the commands in the first place?

Gigowatt:
Quote from: basbas on 2013 February 26, 16:20:49

Oh, that's interesting, thanks. I'll see what I'm going to do with that.

Do you have any idea why it didn't recognise the commands in the first place?

Yes ! The path where the script (BAT) is placed is not a default place where the script looks for commands, such as EXE or other CMD or BAT files.
A script can automatically find commands in specials paths contained in the variables %PATH%, %CD% (current dir) and maybe %TEMP% and others... But "script path" isn't one of these.

I've seen cd /d "%docs%" in your script so %CD% variable (which is a default path where the script can find commands) is not the "script path" anymore when it verifies if commands exist.
The script can recognise wget(.exe) and unzip(.exe) ONLY if they are located at %docs% path :(

There are 3 solutions:
1. In your script, rename all wget and unzip calling commands by %~dp0wget.exe and %~dp0unzip.exe commands.
2. In your script, at the beginning, add the command set path=%~dp0;%path%. This operation add the "script path" to defaults paths where the script can find commands, even if "Current Dir" is defined elsewhere. So have not to modify your script, just add this line and your script can work everywhere.
3. I think this is the best solution BUT it's the solution which requires most modifications. You should NOT use CD command.
Exemple :
Code:

cd /d "AwesomeMod Updater"
echo.%ver% >version.txt
becames
Code:

echo.%ver% >"%data%\AwesomeMod Updater\version.txt"
(and be carefull there is an unecessary space after %ver% !)

I know that for some reasons (especially when you use parenthesis), using a path with special caracters (like (, ), &, ...) into a FOR or IF commands can cause unexpected errors when script executes the command.
The only solution I know is to change "Current Dir" before the FOR or IF command. But there is a better way than CD command, use PUSHD command !
This command is compatible with Vista, 7 and 8 and I think with XP too but has one thing more than CD command, you can reverse your "current dir" variable to the old "current path" with de POPD command. In other words, you can temporarily change "current path" with PUSHD and restore it with POPD.


Suggestions :
1. I've not read entirely your script but I know that you have to define the save path according to language, and it's complicated because you have to translate the name for every languages ! EA engineers are not very smart...
Code:

if "%loc%"=="nl-NL" set "locn=De Sims 3"
if "%loc%"=="fr-FR" set "locn=Les Sims 3"
if "%loc%"=="de-DE" set "locn=Die Sims 3"
if "%loc%"=="pt-PT" set "locn=Os Sims 3"
if "%loc%"=="es-ES" set "locn=Los Sims 3"
I suggest this little piece of script :
Code:

for /f "delims=" %%a in ('dir /b /a:d "%docs%\Electronic Arts"') do (
if exist "%docs%\Electronic Arts\%%a\Mods\Resource.cfg" (
set "locn=%%a"
)
)
Find "Mods\Resource.cfg" in all sub-folders of "%docs%\Etectronic Arts" and if it found, set locn variable with the current name of the sub-folder. It will NOT correctly work if there are more than 1 sub-folder where "Mods\Resource.cfg" can be found because ONLY the last scanned sub-folder will be returned and set into the variable.
To be perfect, all commands where you have to use locn variable should be replaced with this FOR command that I've suggested and set "locn=%%a" would be replaced by the command(s) you want.

2. You were confronted with the "Wow6432Node" problem when you used the REG command. I suggest to use this code :
Code:

set archtype=
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set archtype=Wow6432Node\
if "%PROCESSOR_ARCHITEW6432%"=="AMD64" set archtype=Wow6432Node\
And when you need to use REG command, you can insert archtype variable into the path :
Code:

for /f "tokens=3* delims= " %%A in ('reg query "HKLM\Software\[b]%archtype%[/b]Sims\The Sims 3" /v "Install Dir"') do set game=%%B

3. I've noticed that "AwesomeMod Updater" folder is created into %docs% folder. Why not the "script dir" ? I think that it would be preferable ;)

johnvndnbrk:
Almost as cool as AM!  I just updated my Sims version, which is probably what triggered this.  Nice batch routine with terrific exception handling.  Thanks a mil!

basbas:
Quote from: Gigowatt on 2013 February 26, 18:33:36

The script can recognise wget(.exe) and unzip(.exe) ONLY if they are located at %docs% path

Hence the user is instructed to move wget and unzip to the Windows folder, which means the commands can always be recognised, wherever the script is located.
However, I appreciate your suggestions and agree that your way might be better, as the user has more control and doesn't have to modify the Windows folder. Still, many people (like me) like having the updater script file on the desktop, for quick access to the updater and the game. They wouldn't like having their desktop cluttered with 'unnecessary' files.

Quote

Find "Mods\Resource.cfg" in all sub-folders of "%docs%\Etectronic Arts" and if it found, set locn variable with the current name of the sub-folder. It will NOT correctly work if there are more than 1 sub-folder where "Mods\Resource.cfg" can be found because ONLY the last scanned sub-folder will be returned and set into the variable.
To be perfect, all commands where you have to use locn variable should be replaced with this FOR command that I've suggested and set "locn=%%a" would be replaced by the command(s) you want.

Could you eleborate why you think your method is better? The updater just gets the game language from the registry and checks if it's Dutch, French, German, Portuguese (EU) or Spanish (EU), as those are the only languages that use a different name for the user files folder (De, Les, Die, Os and Los Sims 3 respectively). Other languages just use The Sims 3, therefore that's used if the language isn't one of the aforementioned.
(This is the reason the updater doesn't work with games set to Chinese, Japanese, Korean or Thai, as I have no idea if those characters work or not in a script file.)

Quote

2. You were confronted with the "Wow6432Node" problem when you used the REG command. I suggest to use this code :

That does indeed seem a lot better and more efficient. Thanks.

Quote

3. I've noticed that "AwesomeMod Updater" folder is created into %docs% folder. Why not the "script dir" ? I think that it would be preferable

As mentioned before, if the script dir is, for example, the desktop or another folder that should be kept clean and tidy, it would be polluted with lots of clutter. This is the reason the files are stored in a seperate folder.

EDIT: I added a beta version to the first post, which implements your second suggestion.

Gigowatt:
Yeah, I don't like to add extra-files in my Windows folder too ^^

Quote

Could you eleborate why you think your method is better? The updater just gets the game language from the registry and checks if it's Dutch, French, German, Portuguese (EU) or Spanish (EU), as those are the only languages that use a different name for the user files folder (De, Les, Die, Os and Los Sims 3 respectively). Other languages just use The Sims 3, therefore that's used if the language isn't one of the aforementioned.
I didn't know that other languages (excepted Chinese, Japanese, Korean and Thai) use "The Sims 3" ;) I thought each language had its title.
I think my way will work with all languages (or an error could occur for asian languages, but it will be surprising) and your updater could be universal !

Quote

As mentioned before, if the script dir is, for example, the desktop or another folder that should be kept clean and tidy, it would be polluted with lots of clutter. This is the reason the files are stored in a seperate folder.
I'm ok with your explanation. However, users should not use desktop as a normal folder and only place shortcuts there, but it is their job ! Instead of "%data%", I thought "%data%/Eletronic Arts/%locn%" was a better path. I think game (mods) files should not be mixed with docs files - I know that is just my point of view. Often, I move my save dir on my external hard drive.

Oh, and one more thing ! "skuversion.txt" file is not a necessary file for the game. It can be deleted, modified and the game will still work. "Default.ini" contains the same information (GameVersion = X.X.X.X) and is a more relevant file ;) It's just a detail, but a tool is made of details !

And I've forgotten one important thing : nice work for your updater, it really works and is very usefull. I work with a lot of BAT scripts too and it is a funny game for me to share tips to others who really want to improve their scripts and skills. Confronting your scripts to public is a very good way (the best?) to do it !

Navigation

[0] Message Index

[#] Next page

[*] Previous page