Computer Hope

Software => Computer programming => Topic started by: Ryder17z on April 13, 2009, 02:05:58 AM

Title: Find path in the Win Registery
Post by: Ryder17z on April 13, 2009, 02:05:58 AM
I have tried to make an installer, but the main problem is that I need some kind of script that does this:

-> Find Path: Sims Installation Folder, searching in the registery (Example: C:\Maxis\The Sims\ - if this is the path stored in the registery)

-> Copy files and folders from:
"drive:\folder2\Sims Complete\"
into:
"drive:\folder\"

Does anyone know how to do it?

The best way to create it would be writing in VB or C++ because I don't think any other language has registery support
Title: Re: Find path in the Win Registery
Post by: Reno on April 13, 2009, 02:59:41 AM
reading from registry:
----------------------
batch - use reg.exe
vbscript - regread method
wmi  - StdRegProv
vb6 - access win32 API, and call Reg* API


i think a better way is to use wmi query in vbs, "select * from win32_product"
and then wsh.echo .installlocation
Title: Re: Find path in the Win Registery
Post by: gh0std0g74 on April 13, 2009, 04:30:04 AM
The best way to create it would be writing in VB or C++ because I don't think any other language has registery support
shouldn't make assumptions like that. modern languages like Perl/Python has support (in terms of libraries) for a lot of things (often better than VB/batch). here's an example of Perl interfacing with the windows registry.
Code: [Select]
use Win32::Registry;
my $Register = "Software\\MICROSOFT\\windows";
my $hkey;
$HKEY_LOCAL_MACHINE->Open($Register,$hkey)|| die $!;
$hkey->GetKeys(\@key_list);
print "$Register keys\n";
foreach $key (@key_list)
        {
        print "$key\n";
        }
$hkey->Close();
output
Code: [Select]
C:\test> perl test.pl
Software\MICROSOFT\windows keys
CurrentVersion
ITStorage
Title: Re: Find path in the Win Registery
Post by: Ryder17z on April 13, 2009, 10:56:02 AM
Allright...

I have tried using the REG.exe thing but I haven't found a way to do what i want:

1. How do I get the data from this key:

"HKEY_Local_Machine\Software\Maxis\The Sims\InstallPath"

2. And tell a batch file to copy the files in folder:

"drive:\folder2\Sims Complete\"

to the path stored in the registry (specified above)


A working code would be appreciated
Title: Re: Find path in the Win Registery
Post by: Reno on April 14, 2009, 01:30:07 AM
reg query "HKLM\software\maxis\the sims"

reg query "HKLM\software\maxis\the sims" /v "installpath"

post back the screen result
Title: Re: Find path in the Win Registery
Post by: mroilfield on April 14, 2009, 03:02:16 AM
Just a question here but why are you trying to make an installer for the Sims? If you have the original disc then it should have the installer on it.
Title: Re: Find path in the Win Registery
Post by: Ryder17z on April 15, 2009, 03:25:19 AM
I have downloaded several objects to it and i want to make it easy to install
Title: Re: Find path in the Win Registery
Post by: mroilfield on April 15, 2009, 03:50:38 AM
I have downloaded several objects to it and i want to make it easy to install


I take it this is not a legitimate copy of the Sims or at least not legitimate objects that you have downloaded. I say this because 99.9% of legitimate items already have easy ways to install.
Title: Re: Find path in the Win Registery
Post by: BC_Programmer on April 15, 2009, 04:16:03 AM
he probably created special objects for the sims and wants an installer, so he doesn't have to copy the add-ons himself.

Title: Re: Find path in the Win Registery
Post by: Ryder17z on April 18, 2009, 02:42:33 AM
I have bought The Sims Complete Collection, so no illegal with it so far...


I have...     ...um, let us say about 250 - 800 objects (IFF files) that comes from various sites for The Sims

And I'm trying to create an installer for them, so I don't have to install them manually


Since there exist a "InstallPath" key after you install The Sims, it would be easy if my installer uses the path which I mentioned in first post

reg query "HKLM\software\maxis\the sims"

reg query "HKLM\software\maxis\the sims" /v "installpath"

post back the screen result


I tried them, with same result: Displaying every entry and it's value in "HKLM\software\maxis\the sims\"

Here is what i get:
Code: [Select]
! REG.EXE VERSION 3.0

HKEY_LOCAL_MACHINE\software\maxis\the sims
    SIMS_MUSIC REG_SZ d:\
    SIMS_SOUND REG_SZ C:\Program\Maxis\The Sims\SoundData
    SIMS_DATA REG_SZ C:\Program\Maxis\The Sims
    InstallPath REG_SZ C:\Program\Maxis\The Sims
    Version REG_SZ 1.2
    Language REG_DWORD 0x41d
    SIMS_SKU REG_DWORD 0x2
    SIMS_LANGUAGE REG_SZ Swedish
    EPDInstalled REG_SZ 1
    EPInstalled REG_SZ 1
    Installed REG_SZ 1
    EP3Patch REG_SZ 2
    SIMS_GAME_EDITION REG_SZ 255
    TELEPORT REG_SZ 1
    SIMS_CURRENT_NEIGHBORHOOD_NUM REG_SZ 2
    SIMS_CURRENT_NEIGHBORHOOD_PATH REG_SZ UserData2
    EP2Installed REG_SZ 1
    EP3Installed REG_SZ 1
    EP4Installed REG_SZ 1
    EP5Installed REG_SZ 1
    EP6Installed REG_SZ 1
    EP7Installed REG_SZ 1
    EP8Installed REG_SZ 1
    EPDPatch REG_SZ 1
    EP5Patch REG_SZ 1
Title: Re: Find path in the Win Registery
Post by: Reno on April 18, 2009, 03:28:04 AM
Code: [Select]
@echo off & setlocal & set sim=

set q="HKLM\software\maxis\the sims" /v installpath
for /f "skip=4 tokens=2*" %%a in ('reg query %q%') do set sim=%%b

if defined sim echo copy *.iff "%sim%"
Title: Re: Find path in the Win Registery
Post by: Ryder17z on April 18, 2009, 05:03:34 AM
Thanks Reno, it works but I don't understand how :-\

It copies "filename.iff" to "The Sims\GameData\Userobjects\filename\finename.iff" - which is the correct folder

How does it get that path, I mean it's not in the script or the registery ? (nothing says "GameData\UserObjects")
Title: Re: Find path in the Win Registery
Post by: Reno on April 18, 2009, 07:42:36 AM
It copies "filename.iff" to "The Sims\GameData\Userobjects\filename\finename.iff" - which is the correct folder

what's the one in bold?? is it actual folder name, or you need to extract the info from filename.iff??
Title: Re: Find path in the Win Registery
Post by: Ryder17z on April 18, 2009, 08:16:26 AM
It copies "filename.iff" to "The Sims\GameData\Userobjects\filename\finename.iff" - which is the correct folder

what's the one in bold?? is it actual folder name, or you need to extract the info from filename.iff??

It's a folder name, but I still don't understand how the code actually copy to correct folder
Title: Re: Find path in the Win Registery
Post by: Reno on April 18, 2009, 08:48:15 AM
Code: [Select]
if not defined sim goto:eof
copy "c:\pathto\iff_folder\*.iff" "%sim%\GameData\Userobjects\filename\"


it's just normal copy operation, type copy/? for help
Title: Re: Find path in the Win Registery
Post by: Ryder17z on April 18, 2009, 11:14:38 AM
Yes, but if we look at your code:
Code: [Select]
@echo off & setlocal & set sim=

set q="HKLM\software\maxis\the sims" /v installpath
for /f "skip=4 tokens=2*" %%a in ('reg query %q%') do set sim=%%b

if defined sim echo copy *.iff "%sim%"
Nothing tells it to use "The Sims\GameData\Userobjects\filename\filename.iff"

When I read your code, something tells me the path "The Sims\filename\filename.iff" would be used, which I don't get why isn't

I mean, Where does it get "GameData\UserObjects\" from?
It's not even in the script, or defined in the win registery
Title: Re: Find path in the Win Registery
Post by: Reno on April 18, 2009, 11:49:31 AM
Yes, but if we look at your code:Nothing tells it to use "The Sims\GameData\Userobjects\filename\filename.iff"

I mean, Where does it get "GameData\UserObjects\" from?
It's not even in the script, or defined in the win registery
how would i know where it get the value, why dont you tell me. i am not the one who makes the sim. and i even never play the sims.
i only post code based on your description, assuming %installpath%\gamedata\userobjects\filename\ is the default folder for iff files. ( see below )
It copies "filename.iff" to "The Sims\GameData\Userobjects\filename\finename.iff" - which is the correct folder
Title: Re: Find path in the Win Registery
Post by: Ryder17z on April 18, 2009, 12:25:43 PM
How can I tell you if I don't know the answear? :P


       The path in the script is different than the actual path used
                                 /\                                            /\
                                  |                                             |
                                  |                                             |
                        "The Sims\filename.iff"                           |
                                                                                ||
                                                                                ||
                                  "The Sims\GameData\Userobjects\filename\filename.iff"


I feel confused ???
Title: Re: Find path in the Win Registery
Post by: BC_Programmer on April 19, 2009, 11:16:11 AM
change the path in the script to be the actual path used.  ::)
Title: Re: Find path in the Win Registery
Post by: Ryder17z on April 24, 2009, 06:29:11 AM
No need to do since it works already, but it works like magic, nobody knows how, they just know it works ::)
Title: Re: Find path in the Win Registery
Post by: BC_Programmer on April 24, 2009, 08:56:09 AM
Code: [Select]
set q="HKLM\software\maxis\the sims" /v installpath


this takes it from the registry.