Jump to content











- - - - -

Register DLL


  • Please log in to reply
13 replies to this topic

#1 Guest_Msenn_*

Guest_Msenn_*
  • Guests

Posted 01 February 2008 - 02:05 PM

I use a Dll under VistaPE, that I copy per script to %TargetDir%\Windows\System32.
Unfortunately the Dll isn't registered automatically.
So I have to do it manually with 'regsvr32 Xyz.dll' under VistaPE.
How can I automatically register a Dll in a script?

#2 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 01 February 2008 - 05:07 PM

I use a Dll under VistaPE, that I copy per script to %TargetDir%\Windows\System32.
Unfortunately the Dll isn't registered automatically.
So I have to do it manually with 'regsvr32 Xyz.dll' under VistaPE.
How can I automatically register a Dll in a script?


Hi Msenn,

You could write a .bat file at build-time with:

FileCreateBlank,"%TargetDir%\Windows\System32\reg_xyz.bat"

TXTAddLine,"%TargetDir%\Windows\System32\reg_xyz.bat","regsvr32 xyz.dll","Append"

... and read about the 'api' to find out how to make reg_xyz.bat automatically start at run-time... I'm not exactly sure what is working with your version of VistaPE.

I guess, you can place the code in any App script.

BTW, this may also apply to your earlier post about running 'wpeutil initializenetwork'.

Regards

#3 Arvy

Arvy

    Frequent Member

  • Developer
  • 430 posts
  • Location:Canada, Parry Sound
  • Interests:IT, Outdoors, Horses
  •  
    Canada

Posted 01 February 2008 - 06:21 PM

Or, alternatively, you could do a 'before and after' registry comparison and then, having discovered exactly what is being added by the regsvr32 command, either insert the necessary RegWrite entries into the relevant script or export them to a .reg file for merging. There are examples of both methods in VistaPE's script downloads, but if you need more help with some particulars, don't hestitate to ask.

#4 pscEx

pscEx

    Platinum Member

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

Posted 01 February 2008 - 06:32 PM

In pre-Vista based PEs the easiest way is using one of the next statements in your script.
Which statement is necessary depends on the DLL and you have to check that.
  • RegWrite,"HKLM",0x1,"WB-Software\Microsoft\Windows\CurrentVersion\RunOnceEx\<user number>","<user number>","<yourDLL>|DllInstall|I"
  • RegWrite,"HKLM",0x1,"WB-Software\Microsoft\Windows\CurrentVersion\RunOnceEx\<user number>","<user number>","regsvr32.exe /s <yourDLL>"
Usually 'simple DLLs' demand the second way. The first way is for system DLLs like shell32.exe, browseui.dll etc.

<user number> has to be defined by you. It determinates the order of executing during boot.

Unfortunatelly (because I do not like Vista) I do not have knowledge if this is also valid for Vista. But I'm rather sure.

Peter

#5 Guest_Msenn_*

Guest_Msenn_*
  • Guests

Posted 01 February 2008 - 07:17 PM

Thanks to all, I will possibly test your suggestions on tuesday ...

#6 online

online

    Silver Member

  • Advanced user
  • 767 posts

Posted 01 February 2008 - 07:19 PM

RunOnceEx

I'm very interested: please, psc, why that value is not RunOnce?

#7 2aCD

2aCD

    Frequent Member

  • .script developer
  • 345 posts
  •  
    Germany

Posted 01 February 2008 - 07:43 PM

The most elegant way is, you make a snapshot from the registry in VistPE before and after you run regsvr32 (see arvy).
For making snapshots you can use freeware.

It is not good, if when starting only one registers dll's.

#8 online

online

    Silver Member

  • Advanced user
  • 767 posts

Posted 02 February 2008 - 07:13 AM

why that value is not RunOnce?

Ok, here I found an answer...

Really I had been some problems with "RunOnce" in a my script, and now I know that alternatively I could use "RunOnceEx"...

If your RunOnce entry needs to be executed after certain event, make sure you write the RunOnce registry key after the event, or if you cannot do so, use RunOnceEx. Otherwise you may experience random failures.

Thanks the same... :thumbsup:

#9 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 05 February 2008 - 03:15 PM

In pre-Vista based PEs the easiest way is using one of the next statements in your script.
Which statement is necessary depends on the DLL and you have to check that.

  • RegWrite,"HKLM",0x1,"WB-Software\Microsoft\Windows\CurrentVersion\RunOnceEx\<user number>","<user number>","<yourDLL>|DllInstall|I"
  • RegWrite,"HKLM",0x1,"WB-Software\Microsoft\Windows\CurrentVersion\RunOnceEx\<user number>","<user number>","regsvr32.exe /s <yourDLL>"
Usually 'simple DLLs' demand the second way. The first way is for system DLLs like shell32.exe, browseui.dll etc.

<user number> has to be defined by you. It determinates the order of executing during boot.

Unfortunatelly (because I do not like Vista) I do not have knowledge if this is also valid for Vista. But I'm rather sure.

Peter


Hi psc,

I have tested this method (second way) in 'Standard Project (XP)' :

RegWrite,&#34;HKLM&#34;,0x1,&#34;Tmp_software\Microsoft\Windows\CurrentVersion\RunOnceEx\500&#34;,&#34;234&#34;,&#34;net start wimfltr&#34;

... and it works. Small flash of the Command Window when the shell loads.

I was wondering, what happens if <user numbers> are the same as those used in another script?

Regards

#10 pscEx

pscEx

    Platinum Member

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

Posted 05 February 2008 - 03:26 PM

I was wondering, what happens if <user numbers> are the same as those used in another script?

The latest one (in build) overwrites the previous one :thumbsup:

A reason for me to write the scanProject application.

Peter

#11 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 05 February 2008 - 03:54 PM

The latest one (in build) overwrites the previous one :thumbsup:


Sh....eesh!

Thanks for the warning! I was hoping it might then go alphabetical ... 'n' for 'net start', 'r' for 'regsvr32', etc ...

:D

#12 Arvy

Arvy

    Frequent Member

  • Developer
  • 430 posts
  • Location:Canada, Parry Sound
  • Interests:IT, Outdoors, Horses
  •  
    Canada

Posted 05 February 2008 - 07:57 PM

Sh....eesh! Thanks for the warning! I was hoping it might then go alphabetical ... 'n' for 'net start', 'r' for 'regsvr32', etc ...

It is if you believe MSDN: "The RunOnceEx registry key sorts the entries and sections alphabetically to force a deterministic order."

Actually, it's reasonably possible also to avoid duplicates and consequential overwrites, even in cases of multiple instances using the same primary numeric sequencer key. For example, some alphabetic schema such as the following scriptname-related approach (multiple 999s) can make duplicates/overwrites quite improbable:
RegWrite,HKLM,0x1,&#34;WB-software\Microsoft\Windows\CurrentVersion\RunOnceEx\999&#34;,&#34;XnView&#34;,&#34;||hiderun /w cmd /c#$s#$pSystemDrive#$p\%WorkDir%\%programdir%\xnview_load.cmd&#34;

RegWrite,HKLM,0x1,&#34;WB-software\Microsoft\Windows\CurrentVersion\RunOnceEx\999&#34;,&#34;SSuite&#34;,&#34;||hiderun /w cmd /c #$s#$pSystemDrive#$p\%WorkDir%\%ProgramDir%\syssuite_load.cmd&#34;

RegWrite,HKLM,0x1,&#34;WB-software\Microsoft\Windows\CurrentVersion\RunOnceEx\999&#34;,&#34;ffSfx&#34;,&#34;||hiderun /w cmd /c cd#$s#$q#$pSystemDrive#$p\%WorkDir%\FireFox#$q#$s&&#$s#$qfirefox-


#13 allanf

allanf

    Gold Member

  • .script developer
  • 1256 posts

Posted 06 February 2008 - 06:24 AM

"The RunOnceEx registry key sorts the entries and sections alphabetically to force a deterministic order."


Thanks Arvy...

I thought I was joking in my previous post!

Cheers ... :thumbsup:

#14 Arvy

Arvy

    Frequent Member

  • Developer
  • 430 posts
  • Location:Canada, Parry Sound
  • Interests:IT, Outdoors, Horses
  •  
    Canada

Posted 06 February 2008 - 06:54 AM

I thought I was joking in my previous post!

Heh heh. Well, you might have been. One can never be too sure with Mickeysoft. :thumbsup:

:D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users