George King Posted November 21, 2009 Posted November 21, 2009 (edited) Hi, i´m working on new Windows 7 Update Pack Tool and i wrote this:echo Adding registry weaks to enable RunOnceEx for install Special Updates...REG LOAD HKLM\Slipstream "%WIM%\Windows\System32\Config\Software" >nulSET ROE=HKLM\Slipstream\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %ROE% /v TITLE /d "Installing updates" /f >nulREG ADD %ROE% /v Flags /t REG_DWORD /d "00000014" /f >nulREG ADD %ROE% /d "%WinDir%\System32\rundll32.exe %WinDir%\System32\iernonce.dll,RunOnceExProcess" /f >nulcd SpecialUpdatesset /a NUM=0if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( copy /Y "%%f" "%WIM%\Windows\Setup\Updates" REG ADD %ROE%\00%NUM% /ve /d "%%f" /f REG ADD %ROE%\00%NUM% /v %%f /d "%WinDir%\Setup\Updates\%%f /q" /f set /a NUM+=1 )echo %NUM%pauseREG UNLOAD HKLM\Slipstreamcd..Writing into registry works, but under HKLM\Slipstream\Microsoft\Windows\CurrentVersion\RunOnceEx is only one key 000 i´m used set /a NUM=0 and set /a NUM+=1 in FOR, but i don´t know why REG ADD %ROE%\00%NUM% /ve /d "%%f" /f not working if i make echo %NUM% it give me 3 (in folder are 3 Updates). Don´t know why script write only 000 key. I think it must write key 000, 001, 002 Edited November 21, 2009 by George King Quote
Guest Posted November 21, 2009 Posted November 21, 2009 echo Adding registry weaks to enable RunOnceEx for install Special Updates...REG LOAD HKLM\Slipstream "%WIM%\Windows\System32\Config\Software" >nulSET ROE=HKLM\Slipstream\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %ROE% /v TITLE /d "Installing updates" /f >nulREG ADD %ROE% /v Flags /t REG_DWORD /d "00000014" /f >nulREG ADD %ROE% /d "%WinDir%\System32\rundll32.exe %WinDir%\System32\iernonce.dll,RunOnceExProcess" /f >nulcd SpecialUpdatesset /a NUM=0if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( copy /Y "%%f" "%WIM%\Windows\Setup\Updates" REG ADD %ROE%\00%NUM% /ve /d "%%f" /f REG ADD %ROE%\00%NUM% /v %%f /d "%WinDir%\Setup\Updates\%%f /q" /f goto :increase )echo %NUM%pauseREG UNLOAD HKLM\Slipstreamcd..:increaseset /a NUM+=1goto :eoftry thiswhen i was working on WLM i remember that the for didn't increase until it gets out from the loopi fixed it that way i think try it and tell me Quote
Mr_Smartepants Posted November 21, 2009 Posted November 21, 2009 (edited) MSFN has an excellent resource on ROE.http://unattended.ms...5fe4e2b832a08a/Dark madness is right. You need to declare the number orderSET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %KEY% /V TITLE /D "Installing Applications" /fREG ADD %KEY%\005 /VE /D "Adobe Reader 6" /fREG ADD %KEY%\005 /V 1 /D "%systemdrive%\install\AdobeReader6\AR6.msi /qn" /fREG ADD %KEY%\010 /VE /D "Alcohol 120" /fREG ADD %KEY%\010 /V 1 /D "%systemdrive%\install\alcohol\setup.exe /qn" /fREG ADD %KEY%\010 /V 2 /D "REGEDIT /S %systemdrive%\install\alcohol\register.reg" /f Edited November 21, 2009 by Mr_Smartepants Quote
George King Posted November 21, 2009 Author Posted November 21, 2009 echo Adding registry weaks to enable RunOnceEx for install Special Updates...REG LOAD HKLM\Slipstream "%WIM%\Windows\System32\Config\Software" >nulSET ROE=HKLM\Slipstream\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %ROE% /v TITLE /d "Installing updates" /f >nulREG ADD %ROE% /v Flags /t REG_DWORD /d "00000014" /f >nulREG ADD %ROE% /d "%WinDir%\System32\rundll32.exe %WinDir%\System32\iernonce.dll,RunOnceExProcess" /f >nulcd SpecialUpdatesset /a NUM=0if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( copy /Y "%%f" "%WIM%\Windows\Setup\Updates" REG ADD %ROE%\00%NUM% /ve /d "%%f" /f REG ADD %ROE%\00%NUM% /v %%f /d "%WinDir%\Setup\Updates\%%f /q" /f goto :increase )echo %NUM%pauseREG UNLOAD HKLM\Slipstreamcd..:increaseset /a NUM+=1goto :eoftry thiswhen i was working on WLM i remember that the for didn't increase until it gets out from the loopi fixed it that way i think try it and tell meNot working, look:The script will exit without REG UNLOAD etc and FOR was run only for one time, it must run 3 times (in folder are 3 updates)Any ideas? Quote
5eraph Posted November 22, 2009 Posted November 22, 2009 (edited) You cannot use a changing environment variable in a script loop without using "SETLOCAL EnableDelayedExpansion".Try the following code:SETLOCAL EnableDelayedExpansionecho Adding registry tweaks to enable RunOnceEx for install Special Updates...REG LOAD HKLM\Slipstream "%WIM%\Windows\System32\Config\Software" >nulSET ROE=HKLM\Slipstream\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %ROE% /v TITLE /d "Installing updates" /f >nulREG ADD %ROE% /v Flags /t REG_DWORD /d "00000014" /f >nulREG ADD %ROE% /d "%WinDir%\System32\rundll32.exe %WinDir%\System32\iernonce.dll,RunOnceExProcess" /f >nulcd SpecialUpdatesset /a NUM=0if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( set /a ROENUM=!NUM!*5 If !ROENUM! LSS 10 (set "ROESTR=00!ROENUM!") ELSE ( If !ROENUM! LSS 100 (set "ROESTR=0!ROENUM!") ELSE ( set "ROESTR=!ROENUM!")) copy /Y "%%f" "%WIM%\Windows\Setup\Updates" REG ADD %ROE%\!ROESTR! /ve /d "%%f" /f REG ADD %ROE%\!ROESTR! /v %%f /d "%WinDir%\Setup\Updates\%%f /q" /f set /a NUM+=1 echo. !ROESTR!: "%%f" )echo.echo !NUM! files added to ROE.echo.pauseREG UNLOAD HKLM\Slipstreamcd..This script will properly handle up to 200 files with standard ROE numbering (multiples of 5, starting at 0).And, yes, the exclamation points (!) are absolutely necessary for environment variables that change with EnableDelayedExpansion. Edited November 22, 2009 by 5eraph George King 1 Quote
George King Posted November 22, 2009 Author Posted November 22, 2009 (edited) You cannot use a changing environment variable in a script loop without using "SETLOCAL EnableDelayedExpansion".Try the following code:SETLOCAL EnableDelayedExpansionecho Adding registry tweaks to enable RunOnceEx for install Special Updates...REG LOAD HKLM\Slipstream "%WIM%\Windows\System32\Config\Software" >nulSET ROE=HKLM\Slipstream\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %ROE% /v TITLE /d "Installing updates" /f >nulREG ADD %ROE% /v Flags /t REG_DWORD /d "00000014" /f >nulREG ADD %ROE% /d "%WinDir%\System32\rundll32.exe %WinDir%\System32\iernonce.dll,RunOnceExProcess" /f >nulcd SpecialUpdatesset /a NUM=0if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( set /a ROENUM=!NUM!*5 If !ROENUM! LSS 10 (set "ROESTR=00!ROENUM!") ELSE ( If !ROENUM! LSS 100 (set "ROESTR=0!ROENUM!") ELSE ( set "ROESTR=!ROENUM!")) copy /Y "%%f" "%WIM%\Windows\Setup\Updates" REG ADD %ROE%\!ROESTR! /ve /d "%%f" /f REG ADD %ROE%\!ROESTR! /v %%f /d "%WinDir%\Setup\Updates\%%f /q" /f set /a NUM+=1 echo. File !NUM! processed as !ROESTR!: "%%f" )echo.echo !NUM! files added to ROE.echo.pauseREG UNLOAD HKLM\Slipstreamcd..This script will properly handle up to 200 files with standard ROE numbering (multiples of 5, starting at 0).And, yes, the exclamation points (!) are absolutely necessary for environment variables that change with EnableDelayedExpansion.Wow, it working :thumbsup_anim: . Many thanks.Can you specify for me this code? I´m not sure if understand it... set /a ROENUM=!NUM!*5 If !ROENUM! LSS 10 (set "ROESTR=00!ROENUM!") ELSE ( If !ROENUM! LSS 100 (set "ROESTR=0!ROENUM!") ELSE ( set "ROESTR=!ROENUM!")) Edited November 22, 2009 by George King Quote
5eraph Posted November 22, 2009 Posted November 22, 2009 (edited) That code converts the number of the file it is working on into a proper string to be used for your registry entries.First, the file number (starting at zero) is multiplied by 5, then saved as ROENUM by the SET command.The If statements convert the number !ROENUM! into the proper string !ROESTR! by adding leading zeros where necessary. For example:NUM = ROENUM = ROESTR0 = 0 = 0001 = 5 = 0052 = 10 = 010..19 = 95 = 09520 = 100 = 100..199 = 995 = 995200 = 1000 = 1000At NUM=200 it starts using four-digit ROE numbers, which will break the intended file execution order. ..080085090095100100010051010101510201025103010351040104510510501055.. Edited November 22, 2009 by 5eraph George King 1 Quote
George King Posted November 22, 2009 Author Posted November 22, 2009 Now i understand 100% Thanks a lot 5eraph Quote
5eraph Posted November 22, 2009 Posted November 22, 2009 You're welcome, George King. It's about time I started earning my keep here. Quote
George King Posted November 22, 2009 Author Posted November 22, 2009 Can you help me? I think this can work, but it no. How i can use CMD /C like this?CMD /C DEL /F /S /Q "WinDir%\Setup\Updates"in this (replacing ++++):REG ADD %ROE%\999 /ve /d "Cleaning up..." /f >nulREG ADD %ROE%\999 /v CMD /d "++++" /f >nulI don Quote
5eraph Posted November 22, 2009 Posted November 22, 2009 Try this:REG ADD %ROE%\999 /ve /d "Cleaning up..." /f >nulREG ADD %ROE%\999 /v CMD /d "cmd.exe /q /c Del /F /S /Q \"%WinDir%\Setup\Updates\"" /f >nul Quote
George King Posted November 22, 2009 Author Posted November 22, 2009 Yes, it working, but folder with name Updates isn Quote
5eraph Posted November 22, 2009 Posted November 22, 2009 Use the following code instead of the above:REG ADD %ROE%\999 /ve /d "Cleaning up..." /f >nulREG ADD %ROE%\999 /v CMD /d "cmd.exe /q /c RmDir /S /Q \"%WinDir%\Setup\Updates\"" /f >nul Quote
George King Posted January 17, 2010 Author Posted January 17, 2010 5eraph,I want add the DirectX switch, can you look why it not working? All working, but writing into registry with DX install switch (yes, swith working) wont working. I get error, too much parameters.... Any Ideas?SETLOCAL EnableDelayedExpansionecho.echo Adding registry tweaks to enable RunOnceEx for install SPECIAL Updates...echo.REG LOAD HKLM\Slipstream "%WIM%\Windows\System32\Config\Software" >nulSET ROE=HKLM\Slipstream\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %ROE% /v TITLE /d "Installing updates..." /f >nulREG ADD %ROE% /v Flags /t REG_DWORD /d "00000014" /f >nulREG ADD %ROE% /d "%WinDir%\System32\rundll32.exe %WinDir%\System32\iernonce.dll,RunOnceExProcess" /f >nulcd SpecialUpdatesset /a NUM=0set SWITCH=/qif not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( set /a ROENUM=!NUM!*5 If !ROENUM! LSS 10 (set "ROESTR=00!ROENUM!") ELSE ( If !ROENUM! LSS 100 (set "ROESTR=0!ROENUM!") ELSE ( set "ROESTR=!ROENUM!")) copy /Y "%%f" "%WIM%\Windows\Setup\Updates" >nul REG ADD %ROE%\!ROESTR! /ve /d "%%f" /f >nul if "%%f" == "DirectX*.exe" (set SWITCH=/Q /T:\"%WinDir%\Setup\Updates\DX\" /C:\"%WinDir%\Setup\Updates\DX\dxsetup.exe /silent\" set DirectX=1 ) REG ADD %ROE%\!ROESTR! /v %%f /d "%WinDir%\Setup\Updates\%%f %SWITCH%" /f >nul if "%DirectX%" == "1" set SWITCH=/q set /a NUM+=1 )REG ADD %ROE%\999 /ve /d "Cleaning up..." /f >nulREG ADD %ROE%\999 /v CMD /d "cmd.exe /q /c RmDir /S /Q \"%WinDir%\Setup\Updates\"" /f >nulecho.pauseREG UNLOAD HKLM\Slipstream >nulcd.. Quote
5eraph Posted January 17, 2010 Posted January 17, 2010 (edited) There were a couple reasons it wasn't working, but let's start with the following new code. The relevant portions have been tested as working here, so it should work for you as well.SETLOCAL EnableDelayedExpansionecho.echo Adding registry tweaks to enable RunOnceEx for install SPECIAL Updates...echo.REG LOAD HKLM\Slipstream "%WIM%\Windows\System32\Config\Software" >nulSET ROE=HKLM\Slipstream\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %ROE% /v TITLE /d "Installing updates..." /f >nulREG ADD %ROE% /v Flags /t REG_DWORD /d "00000014" /f >nulREG ADD %ROE% /d "%WinDir%\System32\rundll32.exe %WinDir%\System32\iernonce.dll,RunOnceExProcess" /f >nulcd SpecialUpdatesset /a NUM=0if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( set /a ROENUM=!NUM!*5 If !ROENUM! LSS 10 (set "ROESTR=00!ROENUM!") ELSE ( If !ROENUM! LSS 100 (set "ROESTR=0!ROENUM!") ELSE ( set "ROESTR=!ROENUM!")) copy /Y "%%f" "%WIM%\Windows\Setup\Updates" >nul REG ADD %ROE%\!ROESTR! /ve /d "%%f" /f >nul set "SWITCH=/q" set "FILENAMECHECK=%%f" if /I "!FILENAMECHECK:~0,7!"=="DirectX" ( if /I "!FILENAMECHECK:~-4!"==".exe" ( set "SWITCH=/Q /T:\"%WinDir%\Setup\Updates\DX\" /C:\"%WinDir%\Setup\Updates\DX\dxsetup.exe /silent\"")) REG ADD %ROE%\!ROESTR! /v "%%f" /d "%WinDir%\Setup\Updates\%%f !SWITCH!" /f >nul set /a NUM+=1 )REG ADD %ROE%\999 /ve /d "Cleaning up..." /f >nulREG ADD %ROE%\999 /v CMD /d "cmd.exe /q /c RmDir /S /Q \"%WinDir%\Setup\Updates\"" /f >nulecho.pauseREG UNLOAD HKLM\Slipstream >nulcd..Now for the reasons it wasn't working:if "%%f" == "DirectX*.exe"File names cannot be checked in this way. Asterisks (*) will not be interpreted as wildcards. It was necessary to translate this into a form that can be used in a CMD script. To do this a temporary variable, FILENAMECHECK, was created. Then, substrings of that variable were compared against the strings we're looking for; namely "DirectX" at the beginning and ".exe" at the end. An examination of the code above should show specifically how this is done.[*]REG ADD %ROE%\!ROESTR! /v %%f /d "%WinDir%\Setup\Updates\%%f %SWITCH%" /f >nulVariables that change in a loop and are also expanded in that same loop must be local variables. That means "%SWITCH%" must become "!SWITCH!".By moving "set SWITCH=/q", I also simplified the script. The variable DirectX as it was used is no longer necessary. Edited January 17, 2010 by 5eraph George King 1 Quote
George King Posted January 19, 2010 Author Posted January 19, 2010 (edited) Thanks, i modded to look like this, but the setting NAME not working, can you tell me why please?SETLOCAL EnableDelayedExpansionecho.echo Adding registry tweaks to enable RunOnceEx for install SPECIAL Updates...echo.REG LOAD HKLM\Slipstream "%WIM%\Windows\System32\Config\Software" >nulSET ROE=HKLM\Slipstream\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %ROE% /v TITLE /d "Installing updates..." /f >nulREG ADD %ROE% /v Flags /t REG_DWORD /d "00000014" /f >nulREG ADD %ROE% /d "%WinDir%\System32\rundll32.exe %WinDir%\System32\iernonce.dll,RunOnceExProcess" /f >nulcd SpecialUpdatesset /a NUM=0if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( set /a ROENUM=!NUM!*5 If !ROENUM! LSS 10 (set "ROESTR=00!ROENUM!") ELSE ( If !ROENUM! LSS 100 (set "ROESTR=0!ROENUM!") ELSE ( set "ROESTR=!ROENUM!")) copy /Y "%%f" "%WIM%\Windows\Setup\Updates" >nul REG ADD %ROE%\!ROESTR! /ve /d "%%f" /f >nul set "SWITCH=/q" set "FILENAMECHECK=%%f" if /I "!FILENAMECHECK:~0,7!"=="DirectX" ( if /I "!FILENAMECHECK:~-4!"==".exe" ( set "SWITCH=/Q /T:\"%WinDir%\Setup\Updates\DX\" /C:\"%WinDir%\Setup\Updates\DX\dxsetup.exe /silent\"" set "NAME=DirectX SDK")) if /I "!FILENAMECHECK:~0,15!"=="GamesForWindows" ( if /I "!FILENAMECHECK:~-4!"==".exe" ( set "NAME=Games for Windows - LIVE")) if /I "!FILENAMECHECK:~0,11!"=="PlayReadyPC" ( if /I "!FILENAMECHECK:~-4!"==".msi" ( set "SWITCH=/quiet /norestart" set "NAME=PlayReady PC Runtime")) if /I "!FILENAMECHECK:~0,11!"=="Silverlight" ( if /I "!FILENAMECHECK:~-4!"==".exe" ( set "NAME=Microsoft Silverlight")) if /I "!FILENAMECHECK:~0,16!"=="windows-kb890830" ( if /I "!FILENAMECHECK:~-4!"==".exe" ( set "NAME=Malicious Software Removal Tool")) if /I "!FILENAMECHECK:~0,7!"=="wlsetup" ( if /I "!FILENAMECHECK:~-4!"==".exe" ( set "SWITCH=/silent" set "NAME=Windows Live Essentials")) REG ADD %ROE%\!ROESTR! /v "!NAME!" /d "%WinDir%\Setup\Updates\%%f !SWITCH!" /f >nul set /a NUM+=1 )REG ADD %ROE%\999 /ve /d "Cleaning up..." /f >nulREG ADD %ROE%\999 /v CMD /d "cmd.exe /q /c RmDir /S /Q \"%WinDir%\Setup\Updates\"" /f >nulecho.REG UNLOAD HKLM\Slipstream >nulcd..EDIT: I forget move REG ADD %ROE%\!ROESTR! /ve /d "%%f" /f >nul down and change %%f to !NAME!. I will try, maybe it will work Edited January 19, 2010 by George King Quote
5eraph Posted January 20, 2010 Posted January 20, 2010 (edited) I'm sorry for the delay. I've been away.It looks like NAME should work in your revised code for the instances where you have it defined. The only problem I see is when files are found that don't match your file name checks. This is easily solved with a single line of code, set "NAME=%%f", in the right place as shown in the new code below.Also, most of the files we are looking for end with ".exe". The If statements can be rearranged to simplify the code by writing the check for ".exe" only once. This makes the code far more efficient when a file does not end with ".exe" by reducing the number of checks these files need to go through.EDIT: I forgot to make the changes you mentioned in your last reply. Fixed.SETLOCAL EnableDelayedExpansionecho.echo Adding registry tweaks to enable RunOnceEx for install SPECIAL Updates...echo.REG LOAD HKLM\Slipstream "%WIM%\Windows\System32\Config\Software" >nulSET ROE=HKLM\Slipstream\Microsoft\Windows\CurrentVersion\RunOnceExREG ADD %ROE% /v TITLE /d "Installing updates..." /f >nulREG ADD %ROE% /v Flags /t REG_DWORD /d "00000014" /f >nulREG ADD %ROE% /d "%WinDir%\System32\rundll32.exe %WinDir%\System32\iernonce.dll,RunOnceExProcess" /f >nulcd SpecialUpdatesset /a NUM=0if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( set /a ROENUM=!NUM!*5 If !ROENUM! LSS 10 (set "ROESTR=00!ROENUM!") ELSE ( If !ROENUM! LSS 100 (set "ROESTR=0!ROENUM!") ELSE ( set "ROESTR=!ROENUM!")) copy /Y "%%f" "%WIM%\Windows\Setup\Updates" >nul set "SWITCH=/q" set "NAME=%%f" set "FILENAMECHECK=%%f" if /I "!FILENAMECHECK:~-4!"==".exe" ( if /I "!FILENAMECHECK:~0,7!"=="DirectX" ( set "SWITCH=/Q /T:\"%WinDir%\Setup\Updates\DX\" /C:\"%WinDir%\Setup\Updates\DX\dxsetup.exe /silent\"" set "NAME=DirectX SDK") if /I "!FILENAMECHECK:~0,15!"=="GamesForWindows" ( set "NAME=Games for Windows - LIVE") if /I "!FILENAMECHECK:~0,11!"=="Silverlight" ( set "NAME=Microsoft Silverlight") if /I "!FILENAMECHECK:~0,16!"=="windows-kb890830" ( set "NAME=Malicious Software Removal Tool") if /I "!FILENAMECHECK:~0,7!"=="wlsetup" ( set "SWITCH=/silent" set "NAME=Windows Live Essentials") ) if /I "!FILENAMECHECK:~0,11!"=="PlayReadyPC" ( if /I "!FILENAMECHECK:~-4!"==".msi" ( set "SWITCH=/quiet /norestart" set "NAME=PlayReady PC Runtime")) REG ADD %ROE%\!ROESTR! /ve /d "!NAME!" /f >nul REG ADD %ROE%\!ROESTR! /v "!NAME!" /d "%WinDir%\Setup\Updates\%%f !SWITCH!" /f >nul set /a NUM+=1 )REG ADD %ROE%\999 /ve /d "Cleaning up..." /f >nulREG ADD %ROE%\999 /v CMD /d "cmd.exe /q /c RmDir /S /Q \"%WinDir%\Setup\Updates\"" /f >nulecho.REG UNLOAD HKLM\Slipstream >nulcd.. Edited January 20, 2010 by 5eraph George King 1 Quote
George King Posted March 2, 2010 Author Posted March 2, 2010 Ok, can you again help me please? I need add "fix" which will skip HTML and TXT files. Can you help me? I dont know how i can figure it...set /a NUM=0if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( set /a ROENUM=!NUM!*5 If !ROENUM! LSS 10 (set "ROESTR=00!ROENUM!") ELSE ( If !ROENUM! LSS 100 (set "ROESTR=0!ROENUM!") ELSE ( set "ROESTR=!ROENUM!")) set "SWITCH=/q" set "NAME=%%f" set "FILENAMECHECK=%%f" if /I "!FILENAMECHECK:~-4!"==".exe" ( if /I "!FILENAMECHECK:~0,7!"=="DirectX" ( set "SWITCH=/Q /T:\"%WinDir%\Setup\Updates\DX\" /C:\"%WinDir%\Setup\Updates\DX\dxsetup.exe /silent\"" set "NAME=DirectX Redistributable") if /I "!FILENAMECHECK:~0,15!"=="GamesForWindows" ( set "NAME=Games for Windows - LIVE") if /I "!FILENAMECHECK:~0,11!"=="Silverlight" ( set "NAME=Microsoft Silverlight") if /I "!FILENAMECHECK:~0,16!"=="windows-kb890830" ( set "NAME=Malicious Software Removal Tool") if /I "!FILENAMECHECK:~0,7!"=="wlsetup" ( set "SWITCH=/silent" set "NAME=Windows Live Essentials") if /I "!FILENAMECHECK:~0,8!"=="rootsupd" ( set "NAME=Root Certificates Update") if /I "!FILENAMECHECK:~0,4!"=="msse" ( set "MSSE=1" set "NAME=Microsoft Security Essentials" "%%f" /Q /X:"%WIM%\Windows\Updates\MSSE" set "SWITCH=MSSE\setup.exe /s /runwgacheck /o") ) if /I "!FILENAMECHECK:~0,11!"=="PlayReadyPC" ( if /I "!FILENAMECHECK:~-4!"==".msi" ( set "SWITCH=/quiet /norestart" set "NAME=PlayReady PC Runtime")) if /I "!MSSE!"=="1" (REG ADD %ROE%\!ROESTR! /ve /d "!NAME!" /f >nul REG ADD %ROE%\!ROESTR! /v "!NAME!" /d "%WinDir%\Setup\Updates\!SWITCH!" /f >nul) ELSE (REG ADD %ROE%\!ROESTR! /ve /d "!NAME!" /f >nul REG ADD %ROE%\!ROESTR! /v "!NAME!" /d "%WinDir%\Setup\Updates\%%f !SWITCH!" /f >nul) copy /Y "%%f" "%WIM%\Windows\Setup\Updates" >nul set /a NUM+=1 ) Quote
5eraph Posted March 2, 2010 Posted March 2, 2010 (edited) We can nest most of the code within a couple more If statements to skip TXT and HTML files:if /I NOT "!FILENAMECHECK:~-4!"==".txt" ( if /I NOT "!FILENAMECHECK:~-5!"==".html" (I also simplified your Microsoft Security Essentials file processing using the variable !SETUPPATH!, which allows you to make similar adjustments to files you may add in the future.Here is the final code with all modifications. It is untested.set /a NUM=0if not exist "%WIM%\Windows\Setup\Updates" mkdir "%WIM%\Windows\Setup\Updates" >nulFOR %%f IN ("*.*") DO ( set "FILENAMECHECK=%%f" if /I NOT "!FILENAMECHECK:~-4!"==".txt" ( if /I NOT "!FILENAMECHECK:~-5!"==".html" ( set /a ROENUM=!NUM!*5 If !ROENUM! LSS 10 (set "ROESTR=00!ROENUM!") ELSE ( If !ROENUM! LSS 100 (set "ROESTR=0!ROENUM!") ELSE ( set "ROESTR=!ROENUM!")) set "SWITCH=/q" set "NAME=%%f" set "SETUPPATH=%%f" if /I "!FILENAMECHECK:~-4!"==".exe" ( if /I "!FILENAMECHECK:~0,7!"=="DirectX" ( set "SWITCH=/Q /T:\"%WinDir%\Setup\Updates\DX\" /C:\"%WinDir%\Setup\Updates\DX\dxsetup.exe /silent\"" set "NAME=DirectX Redistributable") if /I "!FILENAMECHECK:~0,15!"=="GamesForWindows" ( set "NAME=Games for Windows - LIVE") if /I "!FILENAMECHECK:~0,11!"=="Silverlight" ( set "NAME=Microsoft Silverlight") if /I "!FILENAMECHECK:~0,16!"=="windows-kb890830" ( set "NAME=Malicious Software Removal Tool") if /I "!FILENAMECHECK:~0,7!"=="wlsetup" ( set "SWITCH=/silent" set "NAME=Windows Live Essentials") if /I "!FILENAMECHECK:~0,8!"=="rootsupd" ( set "NAME=Root Certificates Update") if /I "!FILENAMECHECK:~0,4!"=="msse" ( set "NAME=Microsoft Security Essentials" "%%f" /Q /X:"%WIM%\Windows\Updates\MSSE" set "SETUPPATH=MSSE\setup.exe" set "SWITCH=/s /runwgacheck /o") ) if /I "!FILENAMECHECK:~-4!"==".msi" ( if /I "!FILENAMECHECK:~0,11!"=="PlayReadyPC" ( set "SWITCH=/quiet /norestart" set "NAME=PlayReady PC Runtime")) REG ADD %ROE%\!ROESTR! /ve /d "!NAME!" /f >nul REG ADD %ROE%\!ROESTR! /v "!NAME!" /d "%WinDir%\Setup\Updates\!SETUPPATH! !SWITCH!" /f >nul If /I "!SETUPPATH!"=="%%f" (copy /Y "%%f" "%WIM%\Windows\Setup\Updates")>nul set /a NUM+=1 )) ) Edited March 2, 2010 by 5eraph Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.