[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

batch compare rework

Posted on 2004-11-10
34
Medium Priority
?
398 Views
Last Modified: 2012-06-21

Yes, I would like.

>I'd like to check a couple of things:
>-Do you want to scan remote machines, as well as your own?
>-If so, do you have a list of all the machines in a file? (for example), or do you need to use another utility, or another...?

Yes, mainly remote, I do most of this srcipting from one of my servers
Yes, I have a list it is a single column *.txt file
ex:
XB100R1273498
XB100R11934AE
XB100R12134AB
XB100R125349E
XB104R001349T
XB104R001349S
XB110R000349J
XB100R120349V
XB100R12634A6
XB100R14534AD
XB100R12034AA

>You want the patch installed, and the machine name outputted to a file (as a log), right? In which case; what format do >you want it in? (Or aren't you bothered?), e.g:

Like you have it, is fine.


0
Comment
Question by:CMILLER
  • 17
  • 14
  • 3
34 Comments
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12547882
Okay.. I shall get to work now :-)

[r.D]
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12547936
Ah, I've got another query:
What is the command to REMOTELY install the patches? :o\

We currently have it like so:

KBXXXXX.exe -Q -Z

How is the machine name to install it on specified?

ta,
[r.D]
0
 

Author Comment

by:CMILLER
ID: 12548022
I was going to use psexec.exe on the *.cmd files.

Is that what you mean
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 9

Expert Comment

by:DrWarezz
ID: 12548929
Well, is that the program that you will use to remotely install the Patches?

For Example:

Let's say that you use PSINFO to scan a machine called 'machine1'. You find that it needs the patch 'KB12345.exe' installed. What command would you use to install that patch on that specific machine, remotely?

Because, you're installing all the patches (necessary) on all the machines, remotely, from the one machine, right? So, how do you specify in the code, which machine to install that particular patch on?? If PSEXEC is the program that you'll use for that, what is the Syntax of the command?? (Perhaps type 'PSEXEC /?' and post the results here for me to look at..?).

ta,
[r.D]

Oh, and sorry about the delay. :-)
0
 

Author Comment

by:CMILLER
ID: 12549695
No problem,

Its going to be Friday before I get back with you, somethings come up.
0
 
LVL 10

Expert Comment

by:Longbow
ID: 12553494
You can use Microsoft SUS in order to install patches in your network :
http://www.microsoft.com/windowsserversystem/sus/default.mspx
0
 

Author Comment

by:CMILLER
ID: 12557616
I am already using SUS, the problem is that it doesnt get updated that often, and where I work,
when security updates come out I have to have them deployed within 24 hours.
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12565720
Hey Chris... What is the code to install the patches remotely??

So far, I've coded the following:

:-----8<------------------------------------- FileName.bat -----------------------------------------------:
@ECHO OFF
TITLE Remote Patch Installer
   
   PUSHD %CD%

:** Declare Variables:
   SET MachineFile="c:\directory\MachineNames.txt"
   SET PSINFO="c:\directory\PSINFO.exe"
   SET HotfixDir=c:\patch
   SET HotfixList="c:\directory\Hotfixes.txt"
   FOR %%I in (%0) do SET ThisFile=%%~nI
   

:////////////////////////////////////////////////////////////////////////////////////////////////////
:** Output all available patches to file:
   ECHO. > %HotfixList%
   FOR %%F in (%HotfixDir%\*.exe) do @ECHO %%~nF >>%HotfixList%
   

:////////////////////////////////////////////////////////////////////////////////////////////////////
:** Output Program info:
   ECHO.
   ECHO.
   ECHO %ThisFile% v1.0 - Remote patch installation
   ECHO Copyright (C) %DATE:~-4% Chris Miller ^& Rob Darkins
   ECHO.
   ECHO.
   

:////////////////////////////////////////////////////////////////////////////////////////////////////
:** Verify that machine names file exists:
:MachineFileExist
   
   ECHO Locating Machine List File ...
   
   IF NOT EXIST %MachineFile% (
      ECHO.
      ECHO Cannot locate Machine List File.
      ECHO [Missing File: %MachineFile%]
      ECHO.
      SET /P MachineFile="Please Specify the correct file: "
     
      GOTO :MachineFileExist
   )
   
   ECHO.
   ECHO Located.
   

:////////////////////////////////////////////////////////////////////////////////////////////////////
:** Read the file:
   
   ECHO.
   ECHO Reading machine names ...
   
   FOR /F "tokens=* delims=" %%M in (%MachineFile%) do call :CheckPatches "%%M"
   
   POPD
   
   SET count=4
   :ExitLoop
   ECHO.
   ECHO All Machines have been processed.
   ECHO.
   ECHO [The program will exit in %count% seconds...]
   
   :** Verify that the count is not 0 yet, in which case, EXIT the batch file:
      IF %count% LEQ 0 DEL PATCH.TEMP & EXIT /B
   
   :** Decrement the Seconds Count:
      SET /a count-=1
   
   :** Pause for approximately 1 (rather long) second:
      PING -N 2 LOCALHOST >>NUL
   
   :** Loop back:
      GOTO :ExitLoop
   

:////////////////////////////////////////////////////////////////////////////////////////////////////
:** For every machines passed here as an argument, check for patches that aren't
:     installed on it. Then for every patch not installed, install it remotely:
:CheckPatches
   SET MachineTemp=%~1
   
   :** Output the status:
      ECHO.
      ECHO Checking installed patches on machine: %MachineTemp% ...
      ECHO.
   
   :** Output installed patches on machine to a temp file:
      %PSINFO% -H \\%MachineTemp% > PATCH.TEMP
     
   :** Read all hotfixes in the Hotfix File, if they aren't installed, install them:
      FOR /F "tokens=* delims=" %%H in (%HotfixList%) do call :CheckHotfix "%MachineTemp%" "%%H"
   
   :** Return so that the next machine can be processed:
      EXIT /B
   

:////////////////////////////////////////////////////////////////////////////////////////////////////
:** Check that the hotfix has been installed, if not, install it:
:CheckHotfix
   
   SET MachineCheck=%~1
   SET HotfixToCheck=%~2
   
   FIND /I "%HotfixToCheck%" PATCH.TEMP >>NUL
   SET FLAG=%ERRORLEVEL%
   
   :** Install the patch if not already:
      IF %FLAG% NEQ 0 CALL :INSTALL "%MachineCheck%" "%HotfixToCheck%"
   
   :** Return:
      EXIT /B
   

:////////////////////////////////////////////////////////////////////////////////////////////////////
:INSTALL
   
   SET MachineInstall=%~1
   SET PatchInstall=%~2.exe
   
   :** Install the patch on the machine:
      :** CHANGE ME!
          ECHO.
          ECHO Install Patch: %PatchInstall%
          ECHO Machine:      %MachineInstall%
   
   :** Return:
      EXIT /B
   
:-----8<------------------------------------- FileName.bat -----------------------------------------------:

However, The lines:

      :** CHANGE ME!
          ECHO.
          ECHO Install Patch: %PatchInstall%
          ECHO Machine:      %MachineInstall%

(near the bottom of the code), needs to be changed to the command to actually install the patch. You can use the variables:

%MachineInstall%  and  %PatchInstall% in the command.

I haven't tested it, obviously, because I don't have PSINFO, etc.. nore the same network setup.. But, there it is so far, let me know what you think... and if there are any bugs, and if you need help adding the install command.

gL,
[r.D]
0
 

Author Comment

by:CMILLER
ID: 12565748
ok, thanks

I will try this out today
0
 

Author Comment

by:CMILLER
ID: 12567134
I was goind to use psexec.exe to install

http://www.sysinternals.com/ntw2k/freeware/psexec.shtml
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12567672
Okay; I'll finish the batch file now, and let you know when I'm done :-)

[r.D]
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12568282
Here, once again, I haven't tested it (because I don't have the same network setup, etc, etc), but give this a go:


:-----8<--------------------------------------- FileName.cmd ----------------------------------------------------:
@ECHO OFF
TITLE Remote Patch Installer
   
    PUSHD %CD%
    SETLOCAL ENABLEDELAYEDEXPANSION
   
   
:** Declare variables:
   
    SET MachineFile=c:\directory\MachineNames.txt
    SET PSINFO=c:\directory\PSINFO.exe
    SET PSEXEC=c:\directory\PSEXEC.exe
    SET HotfixDir=c:\patch
    SET HotfixList=hotfixes.temp
    SET LogFile=hotfixes.log
   
    FOR %%I IN (%0) DO SET ThisFile=%%~nI
   
   
:** Output all patches in directory to the Patch file:
   
    ECHO. > %HotfixList%
    FOR %%F IN (%HotfixDir%\*.exe) DO @ECHO %%~nF >>%HotfixList%
   
   
:** Output Program info:
   
    ECHO.
    ECHO.
    ECHO %ThisFile% v1.0 - Remote patch installation
    ECHO Copyright (C) %DATE:~-4% Chris Miller ^& Rob Darkins
    ECHO.
    ECHO
   
   
:** Verify that machine names file exists:
   
:MachineFileExist
   
    ECHO Locating Machine List File ...
   
    IF NOT EXIST "%MachineFile%" (
       ECHO.
       ECHO Cannot locate the file containing the Machine names.
       ECHO [Missing File: %MachineFile%]
       ECHO.
       SET /P MachineFile="Please Specify the correct file: "
       
       GOTO :MachineFileExist
    )
   
    ECHO.
    ECHO Located.
   
   
:** Verify that PSINFO exists:
   
:PSINFOExist
   
    ECHO Locating PSINFO ...
   
    IF NOT EXIST "%PSINFO%" (
       ECHO.
       ECHO Cannot locate PSINFO.
       ECHO [Missing File: %PSINFO%]
       ECHO.
       SET /P PSINFO="Please Specify the correct file: "
       
       GOTO :PSINFOExist
    )
   
    ECHO.
    ECHO Located.
   
   
:** Verify that HotfixDir exists:
   
:HotfixDirExist
   
    ECHO Locating HotfixDir List File ...
   
    IF NOT EXIST "%HotfixDir%" (
       ECHO.
       ECHO Cannot locate HotfixDir.
       ECHO [Missing Directory: %PSEXEC%]
       ECHO.
       SET /P HotfixDir="Please Specify the correct directory: "
       
       GOTO :HotfixDirExist
    )
   
    ECHO.
    ECHO Located.
   
   
:** Process ALL Machine names:
   
    FOR /F "tokens=* delims=" %%M IN (%MachineFile%) DO CALL :IF_EXIST "%%M"
   
    ECHO.
    ECHO Complete.
   
    PING -n 1 LOCALHOST >>NUL
   
    EXIT /B
   
   
:** Verify that all given machine names exist, if so, then continue to the patch section:
:IF_EXIST
   
    SET Machine1=%~1
   
    ECHO.
    ECHO Locating machine [%Machine1%] ...
   
    PING -n 1 %Machine1% >>NUL
   
    IF %ERRORLEVEL% NEQ 0 (
        ECHO.
        ECHO Machine [%Machine1%] cannot be located.
        ECHO.
        EXIT /B
    )
   
    ECHO.
    ECHO Machine [%Machine1%] has been located.
    ECHO.
   
    CALL :IF_PATCH "%Machine1%"
   
    EXIT /B
   
   
:** Check for patches that have not been installed, then install them:
:IF_PATCH
   
    SET Machine2=%~1
    %PSINFO% -h \\%Machine2% > PsInfo.temp
   
    FOR /F "tokens=* delims=" %%P IN (%HotfixList%) DO CALL :INSTALL "%%P" "%Machine2%"
   
    EXIT /B
   
   
:** Check if the patch has been installed, if not, install it:
:INSTALL
   
    SET Patch1=%~1
    SET Machine3=%~2
   
    ECHO.
    ECHO Checking if patch [%Patch1%] exists on machine [%Machine3%] ...
   
    FOR /F "tokens=* delims=" %%L IN (%LogFile%) DO (
        FOR /F "tokens=2 delims=;" %%A in ("%%L") DO IF /I "%%A"=="%Machine3%" ( IF /I "%%B"=="%Patch1%" EXIT /B )
    )
   
    FIND /I "%Patch1%" PsInfo.temp >>NUL
   
    IF %ERRORLEVEL% NEQ 0 (
        ECHO.
        ECHO Installing patch ...
        ECHO Machine: %Machine3%
        ECHO Patch:     %Patch1%
        ECHO.
        %PSEXEC% \\%Machine3% "%Patch1%.exe"
       
        :** Log Machine and Patch to file:
            ECHO %Machine3%;%Patch1% >>%LogFile%
    )
   
    ECHO.
    ECHO Patch is already installed.
    ECHO.
   
    EXIT /B
   
:-----8<--------------------------------------- FileName.cmd ----------------------------------------------------:

Obviously, you need to change the variables at the start of it.. let me know how it goes :-)

gL,
[r.D]
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12568338
Let me just elaborate on the variables near the start of the code:

    SET MachineFile=c:\directory\MachineNames.txt
    SET PSINFO=c:\directory\PSINFO.exe
    SET PSEXEC=c:\directory\PSEXEC.exe
    SET HotfixDir=c:\patch
    SET HotfixList=hotfixes.temp
    SET LogFile=hotfixes.log


MachineFile
--------------
This file is what has the list of all the Machine Names, to remotely install necessary patches on.

PSINFO
--------------
Where PSINFO.exe is located.

PSEXEC
--------------
Where PSEXEC.exe is located.

HotfixDir
--------------
Where all the patches are installed, on your machine.

HotfixList
--------------
A list of all located patches (from inside the %HotfixDir% directory) that are located will be outputted to the %HotfixList% file.

LogFile
--------------
The file to create a log of all installed patches on all machines.


I hope that helps :-)
[r.D]
0
 

Author Comment

by:CMILLER
ID: 12568944
I will try it out today
0
 

Author Comment

by:CMILLER
ID: 12569200
Here is what I got, not to bad the first through.

>PsExec could not start Q828026 .exe on XB100R11934AE:
>The system cannot find the file specified.
It looks like a space, I could not find where to take it out.
Also, I dont know if you remember that are switches that needs to be put in.

The problem is that with M$ hotfixes all the switches are different.
( something i didnt realize until now )

I could not find it in the code, is this something I could modify
as I find out what switches goes with each patch.

Or have I messed you up completely.


************************************
Locating machine [XB100R11934AE ] ...

Machine [XB100R11934AE ] has been located.


PsInfo v1.63 - Local and remote system information viewer
Copyright (C) 2001-2004 Mark Russinovich
Sysinternals - www.sysinternals.com


Checking if patch [ ] exists on machine [XB100R11934AE ] ...

Patch is already installed.


Checking if patch [Q323255 ] exists on machine [XB100R11934AE ] ...

Patch is already installed.


Checking if patch [Q828026 ] exists on machine [XB100R11934AE ] ...

Installing patch ...
Machine: XB100R11934AE
Patch:     Q828026


PsExec v1.55 - Execute processes remotely
Copyright (C) 2001-2004 Mark Russinovich
Sysinternals - www.sysinternals.com


PsExec could not start Q828026 .exe on XB100R11934AE:
The system cannot find the file specified.

Patch is already installed.


Locating machine [XB100R12134AB ] ...

Machine [XB100R12134AB ] has been located.


PsInfo v1.63 - Local and remote system information viewer
Copyright (C) 2001-2004 Mark Russinovich
Sysinternals - www.sysinternals.com

Querying information for XB100R12134AB...^CTerminate batch job (Y/N)? y

C:\patch>
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12569222
Okay.. I have an idea.. I'll get back to you in about 30 mins.. ;-)
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12569561
Okay, firstly, let's see how much of a difference this will make:

(by removing the spaces [which are occuring to a slight bug in the code])..  Locate these lines:


:** Check if the patch has been installed, if not, install it:
:INSTALL
   
    SET Patch1=%~1
    SET Machine3=%~2
   
    ECHO.
    ECHO Checking if patch [%Patch1%] exists on machine [%Machine3%] ...
   
    FOR /F "tokens=* delims=" %%L IN (%LogFile%) DO (
        FOR /F "tokens=2 delims=;" %%A in ("%%L") DO IF /I "%%A"=="%Machine3%" ( IF /I "%%B"=="%Patch1%" EXIT /B )
    )


And replace them with these:


:** Check if the patch has been installed, if not, install it:
:INSTALL
   
    SET Patch1=%~1
    SET Machine3=%~2
    SET Patch1=%Patch1: =%
   
    ECHO.
    ECHO Checking if patch [%Patch1%] exists on machine [%Machine3%] ...
   
    FOR /F "tokens=* delims=" %%L IN (%LogFile%) DO (
        FOR /F "tokens=2 delims=;" %%A in ("%%L") DO IF /I "%%A"=="%Machine3%" ( IF /I "%%B"=="%Patch1%" EXIT /B )
    )


Then save it, and let me know what difference it makes... we'll come to the switches in a few mins..

[r.D]
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12569594
>"I could not find it in the code, is this something I could modify as I find out what switches goes with each patch."

Sure.. if you create a file, with the following format (just replace it with the appropriate data):


PatchCode;switch1;switch2;

So, an example of that format in the file would be:

KB12345;z;q

(I'll add the hyphens (-) to the switches in the code.
:-)

[r.D]
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12569608
btw; you can add as many switches as you want, it don't have to be just two.. you could have something like this if you want:

KB12345;a;b;r;s;z;t;v


Note: add each patch and all the switches (like the example above) on seperate lines in the file.
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12569671
Okay.. I've spotted a few more bugs in the code.. I've altered them, but I will add the code to enable dynamic switches before I post it all here, so give me a short while :-)

[r.D]
0
 

Author Comment

by:CMILLER
ID: 12569702
cool
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12569952
Actually, for the file with the switches in, could you put it like this:
Ex:

KB12345.exe -q -z


Would you mind doing that?? It would save alot of time for myself, and limit bugs, I'm sure ;-)

btw; I'm nearly done with the batch file....

ta,
[r.D]
0
 

Author Comment

by:CMILLER
ID: 12569988
yea, thats fine
0
 
LVL 9

Accepted Solution

by:
DrWarezz earned 2000 total points
ID: 12570040
Okay, let me know how this one performs:

:***********************************************************************************:
@ECHO OFF
TITLE Remote Patch Installer
   
    PUSHD %CD%
    SETLOCAL ENABLEDELAYEDEXPANSION
   
   
:** Declare variables:
   
    SET MachineFile=c:\directory\MachineNames.txt
    SET PSINFO=c:\directory\PSINFO.exe
    SET PSEXEC=c:\directory\PSEXEC.exe
    SET HotfixDir=c:\patch
    SET HotfixList=hotfixes.temp
    SET LogFile=hotfixes.log
    SET SwitchFile=switches.txt
   
    FOR %%I IN (%0) DO SET ThisFile=%%~nI
   
   
:** Output all patches in directory to the Patch file:
   
    DEL %HotfixList% /q >>NUL
    FOR %%F IN (%HotfixDir%\*.exe) DO @ECHO %%~nF >>%HotfixList%
   
   
:** Output Program info:
   
    ECHO.
    ECHO.
    ECHO %ThisFile% v1.0 - Remote patch installation
    ECHO Copyright (C) %DATE:~-4% Chris Miller ^& Rob Darkins
    ECHO.
    ECHO
   
   
:** Verify that the SwitchFile exists:
   
:SwitchFileExist
   
    ECHO Locating SwitchFile ...
   
    IF NOT EXIST "%SwitchFile%" (
       ECHO.
       ECHO Cannot locate the SwitchFile.
       ECHO [Missing File: %SwitchFile%]
       ECHO.
       SET /P MachineFile="Please Specify the correct file: "
       
       GOTO :SwitchFileExist
    )
   
    ECHO.
    ECHO Located.
   
   
:** Verify that machine names file exists:
   
:MachineFileExist
   
    ECHO Locating Machine List File ...
   
    IF NOT EXIST "%MachineFile%" (
       ECHO.
       ECHO Cannot locate the file containing the Machine names.
       ECHO [Missing File: %MachineFile%]
       ECHO.
       SET /P MachineFile="Please Specify the correct file: "
       
       GOTO :MachineFileExist
    )
   
    ECHO.
    ECHO Located.
   
   
:** Verify that PSINFO exists:
   
:PSINFOExist
   
    ECHO Locating PSINFO ...
   
    IF NOT EXIST "%PSINFO%" (
       ECHO.
       ECHO Cannot locate PSINFO.
       ECHO [Missing File: %PSINFO%]
       ECHO.
       SET /P PSINFO="Please Specify the correct file: "
       
       GOTO :PSINFOExist
    )
   
    ECHO.
    ECHO Located.
   
   
:** Verify that HotfixDir exists:
   
:HotfixDirExist
   
    ECHO Locating HotfixDir List File ...
   
    IF NOT EXIST "%HotfixDir%" (
       ECHO.
       ECHO Cannot locate HotfixDir.
       ECHO [Missing Directory: %PSEXEC%]
       ECHO.
       SET /P HotfixDir="Please Specify the correct directory: "
       
       GOTO :HotfixDirExist
    )
   
    ECHO.
    ECHO Located.
   
   
:** Process ALL Machine names:
   
    FOR /F "tokens=* delims=" %%M IN (%MachineFile%) DO CALL :IF_EXIST "%%M"
   
    ECHO.
    ECHO Complete.
   
    PING -n 1 LOCALHOST >>NUL
   
    EXIT /B
   
   
:** Verify that all given machine names exist, if so, then continue to the patch section:
:IF_EXIST
   
    SET Machine1=%~1
   
    ECHO.
    ECHO Locating machine [%Machine1%] ...
   
    PING -n 1 %Machine1% >>NUL
   
    IF %ERRORLEVEL% NEQ 0 (
        ECHO.
        ECHO Machine [%Machine1%] cannot be located.
        ECHO.
        EXIT /B
    )
   
    ECHO.
    ECHO Machine [%Machine1%] has been located.
    ECHO.
   
    CALL :IF_PATCH "%Machine1%"
   
    EXIT /B
   
   
:** Check for patches that have not been installed, then install them:
:IF_PATCH
   
    SET Machine2=%~1
    %PSINFO% -h \\%Machine2% > PsInfo.temp
   
    FOR /F "tokens=* delims=" %%P IN (%HotfixList%) DO CALL :INSTALL "%%P" "%Machine2%"
   
    EXIT /B
   
   
:** Check if the patch has been installed, if not, install it:
:INSTALL
   
    SET Patch1=%~1
    SET Patch1=%Patch1: =%
    SET Machine3=%~2
   
    ECHO.
    ECHO Checking if patch [%Patch1%] exists on machine [%Machine3%] ...
   
    FOR /F "tokens=* delims=" %%L IN (%LogFile%) DO (
        FOR /F "tokens=2 delims=;" %%A in ("%%L") DO IF /I "%%A"=="%Machine3%" ( IF /I "%%B"=="%Patch1%" EXIT /B )
    )
   
    :** Extract the necessary switches for this patch, from the SwitchFile:
        SET SWITCHES=
        FOR /F "tokens=* delims=" %%S in (%SwitchFile%) do CALL :SWITCHES "%%S" "%Patch1%"
   
        IF /I "%SWITCHES%"=="" (
            ECHO.
            ECHO An unexpected error has occured: A switch for the patch has not been retrieved.
            ECHO.
            EXIT /B
        )
       
    FIND /I "%Patch1%" PsInfo.temp >>NUL
   
    IF %ERRORLEVEL% NEQ 0 (
        ECHO.
        ECHO Installing patch ...
        ECHO Machine: %Machine3%
        ECHO Patch:     %Patch1%
        ECHO.
       
        %PSEXEC% \\%Machine3% "%HotfixDir%\%SWITCHES%"
       
        :** Log Machine and Patch to file:
            ECHO %Machine3%;%Patch1% >>%LogFile%
    )
   
    ECHO.
    ECHO Patch is already installed.
    ECHO.
   
    EXIT /B
   
   
:** Create the switches:
:SWITCHES
   
    SET Pass1=%~1
    SET Code1=%~2
   
    IF /I "%Pass1:~0,5%"=="%Code1:~0,5%" SET SWITCHES=%Pass1%
   
    EXIT /B
   
:***********************************************************************************:

Just alter the variable here:
  SET SwitchFile=switches.txt

(which is near the start of the batch file) to wherever the file is, with the Patchname & switches (as specified above).

gL,
[r.D]
0
 

Author Comment

by:CMILLER
ID: 12571060
I thought everything was ok, but if you notice this line

PsExec could not start c:\patch\q828026.exe /quiet /norestart /o /n on XB100R118349Z:
The system cannot find the path specified.

The way you have it, it is going to the \\machinename, but I think the error is
that I dont have c:\patch\q828026.exe on the \\machinename.

If this looks correct to you, I can robocopy the files to all machines


********************************************
C:\patch>patchinstall.cmd

patchinstall v1.0 - Remote patch installation
Copyright (C) 2004 Chris Miller & Rob Darkins

ECHO is off.
Locating SwitchFile ...

Located.
Locating Machine List File ...

Located.
Locating PSINFO ...

Located.
Locating HotfixDir List File ...

Located.

Locating machine [XB100R118349Z] ...

Machine [XB100R118349Z] has been located.


PsInfo v1.63 - Local and remote system information viewer
Copyright (C) 2001-2004 Mark Russinovich
Sysinternals - www.sysinternals.com


Checking if patch [KB840987] exists on machine [XB100R118349Z] ...

Patch is already installed.


Checking if patch [Q323255] exists on machine [XB100R118349Z] ...

Patch is already installed.


Checking if patch [Q828026] exists on machine [XB100R118349Z] ...

Installing patch ...
Machine: XB100R118349Z
Patch:     Q828026


PsExec v1.55 - Execute processes remotely
Copyright (C) 2001-2004 Mark Russinovich
Sysinternals - www.sysinternals.com


PsExec could not start c:\patch\q828026.exe /quiet /norestart /o /n on XB100R118349Z:
The system cannot find the path specified.

Patch is already installed.


Complete.

C:\patch>




0
 

Author Comment

by:CMILLER
ID: 12571073
I wont be back in the office until Monday,
I will work on it then.

Have a good weekend.

Thanks
-Chris
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12572792
Sure thing. Hope you have a good weekend also.

Yeah, perhaps the patch needs to be copied to their machine? If my memory serves me; you should be able to add the /c switch to the PSEXEC command, to copy it to the remote machine.. You may want to do a little testing with the /c switch (or any other method) before we test it with the batch file..

To add the /c switch to PSEXEC, locate the following line (near the top of the batch file):

    SET PSEXEC=c:\directory\PSEXEC.exe

and add the /c switch to the end of that line, like so:

    SET PSEXEC=c:\directory\PSEXEC.exe /c

gL,
[r.D]
0
 
LVL 10

Expert Comment

by:Longbow
ID: 12575265
Another way to manage patches on a network.
You can scan ranges of IP and dispatch the patches.

Microsoft Baseline Security Analyzer (MBSA) Management Pack Guide :
http://www.microsoft.com/downloads/details.aspx?FamilyID=57f9a6a3-35a4-40c8-a5f3-9d598f430366&displaylang=en
Microsoft Baseline Security Analyzer V1.2.1 :
http://www.microsoft.com/technet/security/tools/mbsahome.mspx
0
 

Author Comment

by:CMILLER
ID: 12596591
Rob,

Just wanted to let you know I am still testing, all looks good though.

-Chris
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12596614
Excellent -- Keep me informed :-)

[r.D]
0
 
LVL 10

Expert Comment

by:Longbow
ID: 12599283
This one is new :

Evaluate Microsoft Windows Update Services Now
http://www.microsoft.com/windowsserversystem/wus/default.mspx

Microsoft Windows Update Services Frequently Asked Questions
http://www.microsoft.com/windowsserversystem/wus/faqs.mspx
0
 

Author Comment

by:CMILLER
ID: 12599328
Rob,

Its all good.

Thanks, for taking the time to work through this
with me.

I have learned alot about scripting, with this project.

-Chris
0
 

Author Comment

by:CMILLER
ID: 12599344
Longbow,

Thanks, for the info
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12602895
Glad I could help, Chris -- and thanks for the points :-)

[r.D]
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question