specialk Posted January 25, 2006 Posted January 25, 2006 Can somebody help me write a simple script that would run every hotfix in a directory with the /integrate: switch? I saw it posted in the forums earlier, but for the life of me I can't find the post again. Thanks again for the help
Doc Symbiosis Posted January 26, 2006 Posted January 26, 2006 The following command should do the trick.For /f %i in ('DIR c:\Hotfixes\* /B') DO start /wait %i /integrate:c:\XPCD /qHere I asume, that the Hotfixs are located in c:\Hotfixes and the CD files in c:\XPCD.When you want to run this in a batch, you've got to use %%i instead of %i.
specialk Posted January 29, 2006 Author Posted January 29, 2006 That's the script i was looking for! Thank you. Now, just general questions, what does each one of those switches do, and why do i need %%i instead of %%i if i'm using a batch file?
paradox355 Posted May 12, 2006 Posted May 12, 2006 I found this post which had exactly the example I needed to get started with a batch script to automate my hotfixes. After playing around I came up with a script that can be placed anywhere on your computer allowing you to integrate all of your hotfixes located within one folder while still having other files in that folder and displays the number of files integrated.Here's the code followed by a brief explanation of all the parts:@echo offset hotfix=X:\XP-CD\Hotfixes\set xpcd=X:\XP-CD\XPSP2set x=0FOR /F %%i IN ('DIR %hotfix%KB*.exe /B') DO start /wait %hotfix%%%i /integrate:%xpcd% /qFOR /F %%i IN ('DIR %hotfix%KB*.exe /B') DO set /a x=x+1echo.echo %x% files integrated.Here is the explanation for the code:@echo off Turns off command echoing at the command prompt.set hotfix=X:\XP-CD\Hotfixes\ Sets up an environment variable named "hotfix" representing the location of your hotfixes. Change after the equal sign to where your hotfixes are located. Notice the trailing backslash "\", this is important and must be there for the script to work!set xpcd=X:\XP-CD\XPSP2 Sets up an environment variable named "xpcd" representing the location of your Windows source. Change after the equal sign to where your Windows source is located. Notice that there is no trailing backslash here, once again this is important, as having one there will break the script!set x=0 Sets up an environment variable named "x" with the value of zero. This simply serves as a counter.FOR /F %%i IN ('DIR %hotfix%KB*.exe /B') DO start /wait %hotfix%%%i /integrate:%xpcd% /q This is the same command stated at the beginning of this post, altered for this script. It parses the DIRectory that you set earlier "%hotfix%" for any file starting with KB and ending in .exe (the asterisk is a wildcard that can represent any character in any amount) and assigns the resulting filename to variable %%i. It then executes that file "%%i" with the path "%hotfix%" tacked onto the front of the file using the integrate parameter pointing to the Windows source that you set %xpcd%. The /q executes the file silently.FOR /F %%i IN ('DIR %hotfix%KB*.exe /B') DO set /a x=x+1 This is simply a counter. It adds 1 to the value of x for each file that it finds that matches the parsing filter.echo. This displays a blank line.echo %x% files integrated. This prints to the screen the number of files integrated using the variable x from the counter.Hopefully a few of you will find this as useful as I have and maybe learned something in the process.Enjoy!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now