Jump to content

Recommended Posts

Posted

I am in the process of adding the feature to copy i386 from my unattended CD to my hard drive. I read all the posts on the topic and found two solutions that seem the best to try.

Gosh Method is to use an xcopy script to copy the files

Jazkal Method is to put a second copy of i386 in the $OEM$\$1 folder and use the -o switch with cdimage so as not to suffer from duplicates on your CD.

My problem is adding the source location in the registry so that Windows knows where to go when it needs source files.

Currently this registry file works great but it is not very flexible since I am forced to C: instead of using variables. I tried replacing the C: with %SystemDrive% but then the registy shows exactly that "%SystemDrive%" and when I try to install anything that needs the CD you get the prompt asking for the CD and the default location is %SystemDrive%.

How can I get this to work?

WORKING

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
"Installation Sources"=hex(7):43,00,3a,00,5c,00,49,00,33,00,38,00,36,00,00,00,\
00,00
"SourcePath"="C:"
"ServicePackSourcePath"="C:"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"SourcePath"="C:\\I386"

NOT WORKING

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
"Installation Sources"=hex(7):43,00,3a,00,5c,00,49,00,33,00,38,00,36,00,00,00,\
00,00
"SourcePath"="%SystemDrive%"
"ServicePackSourcePath"="%SystemDrive%"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
"SourcePath"="%SystemDrive%\\I386"


Posted

It's impossible to use system variables in the registry or in inf/hive files. That's a common known fact. It's just if you don't know it :P

The solution to fix this is in most cases to run a batch file that adds the specific settings to the registry, using these system variables in the command. The commandline interpreter will replace it by the 'real' value.

Posted

You actually can use environment variables in the registry. Make the registry value have a type of REG_EXPAND_SZ. Can't do that with REGEDIT.EXE but you can with REGEDT32.EXE. As far as doing it with REG or INF files, you can do it with REG files but its less than desirable considering it shows up as hex and isn't exactly human readable. That's why I prefer to use INF's if I have to use an environment variable.

Example:

HKCR,"CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}","LocalizedString",0x00020000,"%USERNAME% / %COMPUTERNAME%"

0x00020000 is REG_EXPAND_SZ

This will store, literally, "%USERNAME%" and "%COMPUTERNAME%" and won't expand them until they are actually used.

And if you were wondering, that entry I used as an example will display the current username and computername as the text for the "My Computer" icon rather than just saying "My Computer"

Hope this helps.

Posted

You can achieve what you are after in a couple of ways:

Add this to your .cmd file (as Bâshrat the Sneaky stated):

REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v "Installation Sources" /t REG_MULTI_SZ /d "%SystemDrive%\I386" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v SourcePath /t REG_SZ /d "%SystemDrive%" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v ServicePackSourcePath /t REG_SZ /d "%SystemDrive%" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v SourcePath /t REG_SZ /d "%SystemDrive%\I386" /f

Alternatively, (contrary to what Bâshrat the Sneaky said), use an inf:

[Version]
Signature=$CHICAGO$

[DefaultInstall]
AddReg = Reg.Settings

[Reg.Settings]
HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Setup,"Installation Sources",0x10000,"%24%\I386"
HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Setup,SourcePath,,"%24%"
HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Setup,ServicePackSourcePath,,"%24%"
HKLM,SOFTWARE\Microsoft\Windows NT\CurrentVersion,SourcePath,,"%24%\I386"

I suppose for the Installation Sources key, you could forget about the "%SysyemDrive%\I386" bit, and because it's a MULTI_SZ value, put something like this in instead "C:\I386,D:\I386,E:\I386,F:\I386,G:\I386,H:\I386", you would then cover your hard disk and optical drives too!

Posted

Great info guys,

You both beat me back to this post, after the command line suggestion I worked out the same code pretty much. Here is what I was about to post as using in my cmd file

reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v "Installation Sources" /t REG_MULTI_SZ /d "%SystemDrive%\Support\i386" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v SourcePath /d %SystemDrive%\Support /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v ServicePackSourcePath /d %SystemDrive%\Support /f

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v SourcePath /d %SystemDrive%\Support\I386 /f

Good to know also about REG_EXPAND_SZ, I was not aware that you could use variables as long as you use REG_EXPAND_SZ

So if I wanted to use REG_EXPAND_SZ in my reg file I would not be able to import it using regedit /s ?

How would I do an expandable multi value like Installation Sources?

It does seem the simplest method is the 4 reg add lines pasted above and just add them to the install.cmd that kicks off all my stuff.

EDIT

did a test by creating registry entries using REG_EXPAND_SZ with a value of %SystemDrive%\Support but this did not work. I was asked for the CD and the path still was looking for %SystemDrive%\Support so it was never converted.

Not that I need to learn this method since adding the 4 lines to cmd file works but I must be doing something wrong getting the REG_EXPAND_SZ working.

Dennis

Posted

In a reg file, if you were wanting to use the REG_EXPAND_SZ method, your reg would start to look something like this:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
"Installation Sources"=hex(7):43,00,3a,00,5c,00,49,00,33,00,38,00,36,00,00,00,\
00,00;REG_MULTI_SZ (C:\I386)
"SourcePath"=hex(2):25,53,79,73,74,65,6d,44,72,69,76,65,25,00;REG_EXPAND_SZ (%SystemDrive%)
"ServicePackSourcePath"=hex(2):25,53,79,73,74,65,6d,44,72,69,76,65,25,00;REG_EXPAND_SZ (%SystemDrive%)

i.e you would need your variables in hex format....

Posted

I made this reg file using binary data but it still wont work. The paths are correct in the registry (I think?)

reg file

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
"Installation Sources"=hex(7):43,00,3a,00,5c,00,53,00,75,00,70,00,70,00,6f,00,\
 72,00,74,00,5c,00,69,00,33,00,38,00,36,00,00,00,00,00
"SourcePath"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,44,00,72,00,69,\
 00,76,00,65,00,25,00,5c,00,53,00,75,00,70,00,70,00,6f,00,72,00,74,00,00,00
"ServicePackSourcePath"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,44,00,\
 72,00,69,00,76,00,65,00,25,00,5c,00,53,00,75,00,70,00,70,00,6f,00,72,00,74,\
 00,00,00

Here is what the reg looks like

reg.gif

Dennis

Posted

Did you create the keys in the registry editor, and export them out, then find that the reg wouldn't import?

or are you telling us that a REG_EXPAND_SZ key is not working for the SourcePath entries.

I doubt that you can just blindly change all REG_SZ entries for REG_EXPAND_SZ and expect them to work!

Stick with the CMD or INF methods

This would be the INF to match your CMD

[Version]
Signature=$CHICAGO$

[DefaultInstall]
AddReg = Reg.Settings

[Reg.Settings]
HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Setup,"Installation Sources",0x10000,"%24%\Support\i386"
HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Setup,SourcePath,,"%24%\Support"
HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Setup,ServicePackSourcePath,,"%24%\Support"
HKLM,SOFTWARE\Microsoft\Windows NT\CurrentVersion,SourcePath,,"%24%\Support\i386"

Posted

Thanks,

Your right, it already works easily this way and much easier to read in the reg. The info worked perfectly. I will use cmd for cmd importing from my runonce.cmd file and use the inf for quick fixes. Is there a way to use an inf from the command line and have it install or import?

Dennis

Posted

example from cmdlines.txt when inf is in same folder as it

[Commands]
"rundll32.exe setupapi,InstallHinfSection DefaultInstall 128 .\whatever.inf"

example from a cmd

ECHO Applying Whatever.inf
rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 132 "Drive\Path\whatever.inf"

  • 20 years later...
Posted

I could be one of three people still making update packs and addons for Windows Xp and 2003.  This thread provided some insight into a problem I have struggled with involving deleting a locked file at startup.  This code from my  addon for the RyanVM Integrator did not work:

[EditFile]
HIVEDEF.INF,AddReg,Addline5

[Addline5]
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","apphelp.dll",,"%SystemRoot%\Temp\movefile.exe /accepteula %SystemRoot%\System32\apphelp.dll """"

Normally you could use INF variables like %10% and %11% that would be expanded to C:\WINDOWS and C:\WINDOWS\System32 respectively, but these do not work in the hive files in the i386 directory such as hivedef.inf.  Looking at the posts here I did manage to put the command in a batch file to get it to run at startup and generate the PendingFileRenameOperations value in the Session Manager key.  Here is the successful entry in my addon:

[EditFile]
HIVEDEF.INF,AddReg,Addline5

[Addline5]
HKCU,"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce","apphelp.dll",,"cmd.exe /q /c %SystemRoot%\Temp\locked.bat"

This is the content of the batch file:

@echo off

reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v apphelp.dll(2) /t REG_SZ /d "%SystemRoot%\Temp\movefile.exe /accepteula %SystemRoot%\System32\apphelp.dll \""" /f

Exit

As you can see it is possible to include a path variable like %SystemRoot% in a registry value in some circumstances without it having to be expanded by placing it in an expandable string value.   

Posted

the registry ones coming from the .inf file dont translate/expand the environment strings %SystemRoot% to like c:\windows

REG_EXPAND_SZ neither do even tho they have the "expand" syntax with them

when i did this look what it really do they just store the %SystemRoot% string into the registry

so it must be the software that reads the environment strings out and then translate them

 

the most KB upgrades use that "inf installer" that installer can control registry entrys and control files replacements

reading out the inf information you can combine many of KB upgrades to one 

 

for this i written this code:

you have to be careful because it can write to registry strings that are system based, also it can replace files (some need a reboot) - it function the same as a trusted installer (you have to know what you doing here - best would be a virtual machine you can try)

a other reason for this code is that inf installers are not very fast - they are probaly made for smaller amounts of entrys

this one however works very fast 

you also dont need to installer .net or something else first - you can directly go for the entrys you want

you need to open the .dsw files what is written in visual studio 6.0 sometimes called vs6 or vc6

in the past i write something similiar the install time gone down from 12 minutes to 8 seconds - thats a lot

Registry_Entrys -> contain registry entrys

File_Entrys -> file replacements

Registry_Key_Deletes -> deleting registry key entrys

it certainly can fix your related problem too - the code is functional 

the syntax is a bit different

HKLM,SOFTWARE\Microsoft\Windows\CurrentVersion\Setup,"Installation Sources",0x10000,"%24%\Support\i386"

this one would go 

"HKLM\0,SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\0,"Installation Sources"\0,0x10000\0,"whatever_string_is_here\\Support\\i386""

so you have to add a " at the beginning and at the end - for , it gets \0, - \ gets \\

that %24% is not requied it translate a string it put to that value - you can write this string out whatever it represented

custom %% are translated, %SystemRoot% and other environment strings are not

installer.zip

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...