Jump to content











Photo
- - - - -

RegImport, Failed to import


  • Please log in to reply
25 replies to this topic

#1 esgaroth

esgaroth

    Frequent Member

  • .script developer
  • 173 posts
  •  
    United States

Posted 25 June 2008 - 11:47 PM

I am having trouble importing a registry file. Here is the process section in my script.
[process]

ExtractFile,"%ScriptFile%","Folder","test.reg","%BaseDir%\Temp\Test"

RegHiveLoad,"Build","%targetdir%\I386\system32\config\setupreg.hiv"

RegImport,"%BaseDir%\Temp\Test\test.reg"

RegHiveUnload,"Build"

And my test reg file:
Windows Registry Editor Version 5.00



[HKEY_LOCAL_MACHINE\Build\SOFTWARE\Test]

"Test value"="test data"



[HKEY_LOCAL_MACHINE\Build\SOFTWARE\Test\Test 2]

"test value 2"="test data 2"

There may be some obvious formatting that I am not getting right but there wasn't much info on this in the manual so I am only guessing at how its supposed to look.

#2 paraglider

paraglider

    Gold Member

  • .script developer
  • 1743 posts
  • Location:NC,USA
  •  
    United States

Posted 26 June 2008 - 03:16 AM

You are attempting to load the system hive from the wrong directory not the software hive. The software hive is at:

%targetdir%\I386\system32\config\software

The system hive is at:

%targetdir%\I386\system32\setupreg.hiv

#3 esgaroth

esgaroth

    Frequent Member

  • .script developer
  • 173 posts
  •  
    United States

Posted 26 June 2008 - 03:49 AM

I just copied from the example in the manual. I made a few changes after looking through some other examples. Here is what I have now.
ExtractFile,"%ScriptFile%","Folder","test.reg","%BaseDir%\Temp\Test"

RegHiveLoad,"WB-Software","%target_sys%\config\software"

RegWrite,"HKLM","0x1","WB-Software\Test","scripted value","test data"

RegWrite,"HKLM","0x1","WB-Software\Test\Test 2","scripted value 2","test data 2"

RegImport,"%BaseDir%\Temp\Test\test.reg"

RegImport,"C:\test.reg"

RegHiveUnload,"WB-Software"
and in my reg file:
Windows Registry Editor Version 5.00



[HKEY_LOCAL_MACHINE\WB-SOFTWARE\Test]

"imported value"="test data"



[HKEY_LOCAL_MACHINE\WB-SOFTWARE\Test\Test 2]

"imported value 2"="test data 2"

As you can see I tried a couple of RegWrites which work fine. Then I tried a couple of RegImports, both of which give me an error. The first one gives me "failed to import registry file". the second import actually gives me a syntax error for some reason.
Now, if I leave off the RegHiveUnload and then manually import the test.reg file, it is successfully entered in the right location in the registry. I don't understand why I am getting the error. It appears that the ImportReg function is not working.

#4 amalux

amalux

    Platinum Member

  • Tutorial Writer
  • 2813 posts
  •  
    United States

Posted 26 June 2008 - 03:52 AM

I am having trouble importing a registry file. Here is the process section in my script.

[process]

ExtractFile,"%ScriptFile%","Folder","test.reg","%BaseDir%\Temp\Test"

RegHiveLoad,"Build","%targetdir%\I386\system32\config\setupreg.hiv"

RegImport,"%BaseDir%\Temp\Test\test.reg"

RegHiveUnload,"Build"

And my test reg file:
Windows Registry Editor Version 5.00



[HKEY_LOCAL_MACHINE\Build\SOFTWARE\Test]

"Test value"="test data"



[HKEY_LOCAL_MACHINE\Build\SOFTWARE\Test\Test 2]

"test value 2"="test data 2"

There may be some obvious formatting that I am not getting right but there wasn't much info on this in the manual so I am only guessing at how its supposed to look.

I admit, I'm not sure what you're trying to do but couldn't you just convert to WB script and include it as part of the script text:
Hive_Load,HKU

reg_add,0x4,"%reg%\Test","Test value","0"

reg_add,0x4,"%reg%\Test\Test 2","Test value 2","0"

Hive_Unload,HKU

This would eliminate the need to encode the reg file separately, or am I missing something (probably) :)

#5 Galapo

Galapo

    Platinum Member

  • .script developer
  • 3841 posts
  •  
    Australia

Posted 26 June 2008 - 04:05 AM

You're right, RegImport function is not working correctly on mounted hives (but is on OS registry). Only the key is created, not the data beneath the key. Running the following command on the SAME reg file imports correctly:

ShellExecute,Hide,"reg.exe","import C:\test.reg"

I'll post in the WB beta discussion to have this looked into.

Regards,
Galapo.

#6 esgaroth

esgaroth

    Frequent Member

  • .script developer
  • 173 posts
  •  
    United States

Posted 26 June 2008 - 04:07 AM

No your not really missing anything. Its just convention I guess. I like to keep things seperate.
Also I wouldn't have to convert the reg file first even though its pretty easy to use reg2wbs. I won't complain to much if I have to convert it but I would use the RegImport if it worked.

I noticed that the way you wrote that code is different than what I am using. Where is that from, I didn't see that in the help file.

#7 amalux

amalux

    Platinum Member

  • Tutorial Writer
  • 2813 posts
  •  
    United States

Posted 26 June 2008 - 07:04 AM

No your not really missing anything. Its just convention I guess. I like to keep things seperate.
Also I wouldn't have to convert the reg file first even though its pretty easy to use reg2wbs. I won't complain to much if I have to convert it but I would use the RegImport if it worked.

I noticed that the way you wrote that code is different than what I am using. Where is that from, I didn't see that in the help file.

Use THIS version of Reg2WBS and be sure to check the API option :)

#8 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 26 June 2008 - 07:34 AM

No your not really missing anything. Its just convention I guess. I like to keep things seperate.
Also I wouldn't have to convert the reg file first even though its pretty easy to use reg2wbs. I won't complain to much if I have to convert it but I would use the RegImport if it worked.

I noticed that the way you wrote that code is different than what I am using. Where is that from, I didn't see that in the help file.


Will be fixed in Beta 4!

Peter

#9 amalux

amalux

    Platinum Member

  • Tutorial Writer
  • 2813 posts
  •  
    United States

Posted 11 June 2009 - 07:34 PM

You're right, RegImport function is not working correctly on mounted hives (but is on OS registry). Only the key is created, not the data beneath the key. Running the following command on the SAME reg file imports correctly:

ShellExecute,Hide,"reg.exe","import C:\test.reg"

I'll post in the WB beta discussion to have this looked into.

Regards,
Galapo.

I know this is an old topic, I'm hoping to resurrect it ;)

The above and RegImport is not working for me, no errors but nothing imported. Is there a working script (livexp) with this option or ?? -- Any help is appreciated ;)

#10 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 11 June 2009 - 08:03 PM

I know this is an old topic, I'm hoping to resurrect it ;)

The above and RegImport is not working for me, no errors but nothing imported. Is there a working script (livexp) with this option or ?? -- Any help is appreciated ;)

Hi Amalux!

It is really old!

Can you post (or PM me, if rather big) the *.reg and the command(s)?

I think that it could be fixed in RC2. (Similar I already told one year ago ... :) )

Peter

#11 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 11 June 2009 - 08:40 PM

. Is there a working script (livexp) with this option or ?? -- Any help is appreciated ;)

Check saydin77's scripts, he uses this feature in a way you'll understand after a short inspection. (ex: check saydin77's IE06 script)

I never use this feature since this is annoying because it is not logable.
A short while ago fxscrpt cleaned .reg files from usb scripts, sadly in mmc script there still exists, i cant remember the reason why exists in mmc script. (maybe ascii related maybe sth else...). Be sure we avoid using .reg files in project, that is why we cant put saydin's scripts into project ;).

I advice you to avoid using this feature but in the end, this is up to you :)

#12 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 11 June 2009 - 08:55 PM

Some old posts which show the real issue:

The *.reg file cannot know the mounted WB name.
And WB cannot know where to write!

thanx peter for reply.



my concept is to give to user the option to load license keys from a reg file. So, I hopefully and optimisticly keep trying to cancel any Murfy's law, and contrary to quantum mechanics predict the positive results. sporty89.gif sporty98.gif

black magic strikes my registry hives vampire.gif


Even the highest optimism cannot bypass the fact that to write into a mounted hive, the reg key has to be changed to meet the target's name.

Peter


Peter, have a nice day.

Do you mean that the entry


HKEY_LOCAL_MACHINE\SOFTWARE\Licenses

have to be

HKEY_LOCAL_MACHINE\WB-Software\Licenses

?

Isn't there any automated way to do it by winbuilder at building time? biggrin.gif:


For this case it is correct. For other .reg input it may be very different, e.g. with CLSID.

Unfortunatelly I do not see a way for WinBuilder to automate this.
Even the TXTREPLACE is (currently) not possible, because the .reg is an unicode file.

Peter


BTW: I have the feeling, that for API based work the mount name can be defined and be fixed.
But in straight programmed scripts: No chance.

BTW2: If there is no bug in RegImport (I do not know, it is historic and I never touched the source) the same question of 'mount name' is in the reg.exe alternity.

Peter

#13 amalux

amalux

    Platinum Member

  • Tutorial Writer
  • 2813 posts
  •  
    United States

Posted 11 June 2009 - 09:05 PM

Hi Amalux!

It is really old!

Can you post (or PM me, if rather big) the *.reg and the command(s)?

I think that it could be fixed in RC2. (Similar I already told one year ago ... ;) )

Peter

Thanks Peter ;)

I'm trying variants of:
RegImport,"C:\test.reg"
ShellExecute,Hide,"reg.exe","import C:\test.reg"

with and w/out hive load/unload,default bookends because I'm not sure how that's supposed to be handled. I'm using a simple test.reg which I know imports to PE correctly. Attached File  test.rar   632bytes   542 downloads

#14 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 11 June 2009 - 09:15 PM

Thanks Peter ;)

I'm trying variants of:
RegImport,"C:\test.reg"
ShellExecute,Hide,"reg.exe","import C:\test.reg"

with and w/out hive load/unload,default bookends because I'm not sure how that's supposed to be handled. I'm using a simple test.reg which I know imports to PE correctly. Attached File  test.rar   632bytes   542 downloads

Thanks, Amalux. I looked into the *.reg.

That is exactly the issues i mentioned in my previous post (maybe because of post crossing you did not read it yet)

The *.reg is an image of the host registry ([HKEY_CURRENT_USER\Software\Elcom])
And it should be imported into HKLM\?????\Elcom or HKLM\*****\Software\Elcom
Here is ????? any random name the script author defined when opening the software hive and ***** any random name the script author defined when opening the default hive.

Really not unsolvable (I estimate about 5 Latin Minutes or 1 German day), but because it is not needed in any of the 'standard' projects, there is no actual necessarity to create a solution.

Maybe:
  • For the very few cases where it is used the walkaround by saydin77 should be used
  • WinBuilder says 'goodbye' to RegImport
Peter

#15 amalux

amalux

    Platinum Member

  • Tutorial Writer
  • 2813 posts
  •  
    United States

Posted 11 June 2009 - 09:47 PM

Thanks Peter,

Yes, I missed the other post and Lancelot's as well, I'll look into saydin77's method, thanks to both of you ;)

;)

#16 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 11 June 2009 - 11:06 PM

Hi amalux,

What is your purpose with .reg adding ???

putting a license reg file provided by the user?
only curiosity ???
trying to add a unicode entry ??
or ???
;)

#17 amalux

amalux

    Platinum Member

  • Tutorial Writer
  • 2813 posts
  •  
    United States

Posted 12 June 2009 - 06:06 AM

Hi amalux,

What is your purpose with .reg adding ???

putting a license reg file provided by the user?
only curiosity ???
trying to add a unicode entry ??
or ???
;)

Comes in handy with portable apps in PE, etc.

I found a way to do it using one of my favorite tools and a trick I learned from Galapo...
ExtractFile,%ScriptFile%,Folder,reg2WBSprg.exe,%ProjectTemp%

ShellExecute,"Hide","%ProjectTemp%\reg2WBSprg",-f%pFileBox1% -o%ProjectTemp%\addregfile.txt -h -e -a -rProcess

Run,%ProjectTemp%\addregfile.txt,Process

;)

#18 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 12 June 2009 - 07:42 AM

Comes in handy with portable apps in PE, etc.

I found a way to do it using one of my favorite tools and a trick I learned from Galapo...

ExtractFile,%ScriptFile%,Folder,reg2WBSprg.exe,%ProjectTemp%

 ShellExecute,"Hide","%ProjectTemp%\reg2WBSprg",-f%pFileBox1% -o%ProjectTemp%\addregfile.txt -h -e -a -rProcess

 Run,%ProjectTemp%\addregfile.txt,Process

;)

Good solution. ;)

I did not even remember this possibility of my program :)


Peter

#19 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 12 June 2009 - 10:07 AM

Comes in handy with portable apps in PE, etc.

Still dont understand the purpose but glad you find a logable solution (I remember it from somewhere in the past......, took down reminder notes, thanks ;) )

Also saydin77 pmed me and adviced you to look [reg-import] section in kaspersky2010 script , he warned to use ascii reg files . Not a general but another method, a very nice piece i advice you to read ;) . (can be improved to be general, but still not logable).
Btw, as far as i understand, saydin77 uses this solution in order to make faster build scripts.

Since non-cooperative wb development maybe having a hidden agenda/purpose in mind causing not having plans for regimport which also cause scattered ways to use importing .reg files around by script writers for a long while, maybe Pedro like to have this reg2wbs solution as an api command.

Sth like: Reg_Import,%folder%,My_RegFile.reg

At least we may have a logable and easy to use api command. Hopefully one day with regimport we may get the speed advantage too, who knows maybe next year maybe tomorrow.....

I pmed Pedro, I hope Pedro like the idea.

#20 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 12 June 2009 - 11:18 AM

Sth like: Reg_Import,%folder%,My_RegFile.reg
I pmed Pedro, I hope Pedro like the idea.

Ok ;)

#21 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 12 June 2009 - 03:48 PM

Ready for next api
[Import_Reg]

//Syntax==>  Reg_Import,My_RegFile.reg

If,Not,ExistFile,%tools%\reg2WBSprg.exe,Begin

  Set,%reg2WBpath%,http://livexp.boot-land.net/repository

  WebGet,%reg2WBpath%/reg2WBSprg.exe,%Tools%\reg2WBSprg.exe

End

ShellExecute,"Hide","%Tools%\reg2WBSprg.exe","-f#1 -o%ProjectTemp%\addregfile.txt -h -e -a -rProcess"

Run,%ProjectTemp%\addregfile.txt,Process
Is it possible to have the program Reg2WBSprg.exe at http://livexp.boot-land.net/repository
Like ExpEnvVar and Hiderun

#22 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 12 June 2009 - 03:55 PM

Is it possible to have the program Reg2WBSprg.exe at http://livexp.boot-land.net/repository
Like ExpEnvVar and Hiderun

The actual version always is is downladable from http://nativeex.boot.../reg2WBSprg.zip

It may bring troubles when different versions are distributed on different servers.

Peter

#23 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 12 June 2009 - 04:30 PM

Ok , Thanks
[Import_Reg]

//Syntax==>  Reg_Import,My_RegFile.reg

If,Not,ExistFile,%tools%\reg2WBSprg.exe,Unpack,http://nativeex.boot-land.net//Programs/reg2WBS/reg2WBSprg.zip\,reg2WBSprg.zip,,%Tools%,.,reg2WBSprg.exe

ShellExecute,"Hide","%Tools%\reg2WBSprg.exe","-f#1 -o%ProjectTemp%\addregfile.txt -h -e -a -rProcess"

Run,%ProjectTemp%\addregfile.txt,Process


#24 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 12 June 2009 - 04:34 PM

Ok , Thanks

[Import_Reg]

 //Syntax==>  Reg_Import,My_RegFile.reg

 If,Not,ExistFile,%tools%\reg2WBSprg.exe,Unpack,http://nativeex.boot-land.net//Programs/reg2WBS/reg2WBSprg.zip\,reg2WBSprg.zip,,%Tools%,.,reg2WBSprg.exe

 ShellExecute,"Hide","%Tools%\reg2WBSprg.exe","-f#1 -o%ProjectTemp%\addregfile.txt -h -e -a -rProcess"

 Run,%ProjectTemp%\addregfile.txt,Process

Maybe I have to change something, or you have to do so:

The zip contains the CMD line reg2WBSprg.exe AND a GUI wrapper reg2WBS.exe

Peter

#25 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 12 June 2009 - 06:15 PM

Is it possible to have the program Reg2WBSprg.exe at http://livexp.boot-land.net/repository
Like ExpEnvVar and Hiderun

Done, i put Reg2WBSprg.exe (v3.02) (md5: E1C2EEC9C5A5F94232D26E13F6F9D7CB) to http://livexp.boot-land.net/repository .

Since we can not know what will happen later to Reg2WBSprg.exe, maybe it is a better idea for api.script containing Reg2WBSprg.exe attached inside, and better to extract to %Tools%\apitools folder.

Further, you decide ;)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users