Jump to content

Running one file from cd from detachedprogram.


Recommended Posts

DetachedProgram=".\system32\cmd.exe"
Arguments="/C START FOR /F usebackq %I IN (`FINDSTR dospath %SystemRoot%\SYSTEM32\$WINNT$.INF`) DO FOR %J IN (%I$OEM$\Files\Drivers.exe) DO IF NOT %J==dospath (FOR %K IN (%J=EXIT) DO IF NOT %K==EXIT (%K -y /q /r:n -o%SystemRoot%\Temp) ELSE (IF NOT %J==Arguments %K))"

Drivers.exe is my 7-zip archive and -olocation is where it is extracted to.

Don't forget to update your OemPnPDriversPath.

I haven't tested this with an actual installation but this command does work in a command prompt.

The commands (START FINDSTR FOR IF) used here also work when called from a BAT file using cmd.exe and /C START from DetachedProgram so this should work, unless there is a length limit on Arguments and this exceeds it. It is quite long.

Please post with your experiences :)

Update: Ok I have found a problem with this and am working on it :rolleyes:

Update #2: Ok, extracting now works. The problem is that it will also try to run:

"/C$OEM$\Files\$OEM$.exe EXIT -y /q /r:n -oC:\WINDOWS\Temp

Thats not a valid path though so shouldn't be a problem.

Actually, after some thinking, this can be used to run more than one program from cd using DetachedProgram during T-39. There could be a text file on the cd with the filenames of the programs to run and use another FOR statement to parse it and run them.

Link to comment
Share on other sites


To run multiple files:

DetachedProgram=".\system32\cmd.exe"
Arguments="/C START FOR /F usebackq %I IN (`FINDSTR dospath %SystemRoot%\SYSTEM32\$WINNT$.INF`) DO FOR %J IN (%I$OEM$\Files\commands.txt) DO IF NOT %J==dospath (FOR %K IN (%J=EXIT) DO IF NOT %K==EXIT (FOR /F %L IN (commands.txt) DO %L) ELSE (IF NOT %J==Arguments %K))"

Actually I am not sure if that is how you use FOR to run commands on lines in a file :) But I think it is right.

A more cleaned up version could be:

DetachedProgram=".\system32\cmd.exe"
Arguments="/C START FOR /F usebackq %I IN (`FINDSTR dospath %SystemRoot%\SYSTEM32\$WINNT$.INF`) DO FOR %J IN (%I$OEM$\Files\commands.txt) DO IF NOT %J==dospath (IF NOT %J==Arguments) FOR %K IN (%J) DO %K

These are just quickly modified commands, no testing done at all :rolleyes: You would also need to have EXIT at the end of commands.txt for the 2nd one.

Link to comment
Share on other sites

i386\WINNT.SIF:

[GuiUnattended]
   DetachedProgram = ".\system32\cmd.exe"
   Arguments="/Q /C FOR /F %I IN (%SystemRoot%\system32\$winnt$.inf) DO (FOR %J IN (%I$OEM$\Detached.cmd) DO (IF EXIST %J (START /MIN %J)))"

$OEM$\Detached.cmd:

@ECHO OFF
::change CurrentDirectory to where script is
CD /D "%~dp0"
::extracting $$ into SystemRoot
.\$$.exe -y -o"%SystemRoot%"
.\$1.exe -y -o"%SystemDrive%"
::extracting Intel INF
.\DRV\IntelINF.exe -y -o"%SystemRoot%\INF"
::extracting RyanVM SATA/Raid drivers repacked
.\DRV\RaidDRV.exe -y -o"%SystemDrive%\DRV"
::extracting drivers sfx
.\DRV\DRV_SFX.exe -y -o"%SystemDrive%\DRV"
EXIT

Tested and confirmed.

Works even with OemPreinstall=No, everything executes on disc. $OEM$\$$ and $OEM$\$1 compressed with 7zip console SFX, no textmode copying needed. Also works on multi boot/source disc.

Link to comment
Share on other sites

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...