[Batch] Automate .msu and .cab updates

Discussion in 'Scripting' started by wk-952, Jun 27, 2014.

  1. oldsh_t

    oldsh_t MDL Expert

    Dec 23, 2009
    1,081
    532
    60
    Well I checked this out and I don't see where WUSA has anything to do with installing or passing by if already installed updates.
    Here is what I did:
    I Took 5 msu updates that were already installed on my system and tried to install them one by one manually. They all checked my system first and said that they were already installed, so the did not reinstall.

    Then I took NICK@NUMBER11 and s1ave77 bat file and changed WUSA "%%A" /quiet /norestart to WUSA "%%A" /passive
    Same result on the same 5 msu updates. They would pop up saying they were already installed.

    One more try with this bat file, No WUSA
    Again same results they would not install because they were already installed.

    Conclusion here is that it is the msu installer themselves that are passing by the installed updates and not because of WUSA

    Or am I missing something??
     
  2. Flipp3r

    Flipp3r MDL Expert

    Feb 11, 2009
    1,965
    908
    60
    I think the point made was that if they are already installed, they won't be re-installed not matter what method is used...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. wk-952

    wk-952 MDL Member

    Sep 2, 2012
    116
    287
    10
    #23 wk-952, Oct 14, 2014
    Last edited: Oct 14, 2014
    (OP)
    @oldsh_t

    as Flipp3r told you, also actually what happens when you attempt to install a .msu update by opening it (as i guess this what you did with the last 'for' loop)
    the Windows just sends its complete path and filename to "WUSA.exe" which in turn attempts to extract the .msu update package first before doing the comparison
    to see whether this update is installed or not.

    so what i'm trying to tell you is that, not the msu installer that does the check but WUSA.exe,
    and yes you're right they're not going to be installed again but skipped.

    EDIT:
    to proof the idea that WUSA.exe is responsible for installing .msu files (by a trivial example) even if you double clicked them (opened them as standalone installers),
    simply create an empty text file and change its extension to .msu then try to open it,
    you'll get an error message from wusa saying: "The file or directory is corrupted and unreadable"
    if this was a standalone installer you'll get the error message that you usually see when opening a corrupted executable file,
    not a message from wusa.
     
  4. oldsh_t

    oldsh_t MDL Expert

    Dec 23, 2009
    1,081
    532
    60
    The point made was (in red above)
    And through my tests I found WUSA has nothing to do with it
     
  5. oldsh_t

    oldsh_t MDL Expert

    Dec 23, 2009
    1,081
    532
    60
    Thanks..... now That I understand. So you don't really have to put WUSA in a script then??
     
  6. wk-952

    wk-952 MDL Member

    Sep 2, 2012
    116
    287
    10
    sure, like you did just loop through each file and start it with the required parameters/switches
    and its location with switches will be sent to wusa automatically
     
  7. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,237
    911
    60
    #27 Chibi ANUBIS, Jan 12, 2015
    Last edited by a moderator: Apr 20, 2017
    My idea for install updates :) :

    Code:
    @echo off
    set ARCH=%PROCESSOR_ARCHITECTURE%
    echo %ARCH%
    if %ARCH%==x86 (
    call "%~dp0commands.bat" "%~dp0x86" "y" "n" "" "x"
    ) else (
    call "%~dp0commands.bat" "%~dp0x64" "y" "n" "" "x"
    )
    exit
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. wk-952

    wk-952 MDL Member

    Sep 2, 2012
    116
    287
    10
    #28 wk-952, Jan 12, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    yep, will work as expected.
    also you could make it a little bit shorter:
    Code:
    @echo off
    set ARCH=%PROCESSOR_ARCHITECTURE%
    echo %ARCH%
    if %ARCH%==x86 (set "updatesDir=%~dp0x86") else (set "updatesDir=%~dp0x64")
    call "%~dp0commands.bat" "%updatesDir%" "y" "n" "" "x"
    exit
    
    you know, just to type the 'call' statement only once and make it maintainable
    in case you want to change the parameters sent to the script later on, you would
    then have to change it only once.

    Edit:
    also if you want to install .cab updates, you might want to add the sixth parameter "runAs" :
    Code:
    call "%~dp0commands.bat" "%updatesDir%" "y" "n" "" "x" "runAs"
    since DSIM.exe requires an elevated script
     
  9. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,237
    911
    60
    #29 Chibi ANUBIS, Jan 13, 2015
    Last edited by a moderator: Apr 20, 2017
    Thanks for the info, I run always the script in administrator privilege :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. chrmai69

    chrmai69 MDL Novice

    Jan 5, 2014
    8
    1
    0
    thanks!!!!!
     
  11. Chibi ANUBIS

    Chibi ANUBIS MDL Chibi Developer

    Apr 28, 2014
    1,237
    911
    60
    Thanks for the update :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...