+ Post New Thread
Results 1 to 4 of 4
Scripts Thread, Think I need a "for.." loop... in Coding and Web Development; Current: Code: @ echo off REM script to install windows 7 hotfixes. cls echo installing KB2492806-x64 ... Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2492806-x64.msu /quiet ...
  1. #1

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,521
    Thank Post
    1,333
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199

    Think I need a "for.." loop...

    Current:

    Code:
     @echo off
    REM script to install windows 7 hotfixes.
    cls
    echo installing KB2492806-x64 ...
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2492806-x64.msu /quiet /norestart
    echo installing KB2505438-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2505438-x64.msu /quiet /norestart
    echo installing KB2505454-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2505454-x64.msu /quiet /norestart
    echo installing KB2510636-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2510636-x64.msu /quiet /norestart
    echo installing KB2523887-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2523887-x64.msu /quiet /norestart
    echo installing KB2524478-v2-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2524478-v2-x64.msu /quiet /norestart
    echo installing KB2525332-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2525332-x64.msu /quiet /norestart
    echo installing KB2547244-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2547244-x64.msu /quiet /norestart
    echo installing KB2555428-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2555428-x64.msu /quiet /norestart
    echo installing KB2561285-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2561285-x64.msu /quiet /norestart
    echo installing KB2561708-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2561708-x64.msu /quiet /norestart
    echo installing KB2578159-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2578159-x64.msu /quiet /norestart
    echo installing KB2580119-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2580119-x64.msu /quiet /norestart
    echo installing KB2581608-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2581608-x64.msu /quiet /norestart
    echo installing KB2582112-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2582112-x64.msu /quiet /norestart
    echo installing KB2610379-v2
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2610379-v2-x64.msu /quiet /norestart
    echo installing KB2617858-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2617858-x64.msu /quiet /norestart
    echo installing KB2625434-x6
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2625434-x64.msu /quiet /norestart
    echo installing KB2640148-v2-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2640148-v2-x64.msu /quiet /norestart
    echo installing KB2645611-v2-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2645611-v2-x64.msu /quiet /norestart
    echo installing KB2655998-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2655998-x64.msu /quiet /norestart
    echo installing KB2661001-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2661001-x64.msu /quiet /norestart
    echo installing Windows6.1-KB2673042-v2-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2673042-v2-x64.msu /quiet /norestart
    echo installing Windows6.1-KB2675785-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2675785-x64.msu /quiet /norestart
    echo installing KB2685893-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2685893-x64.msu /quiet /norestart
    echo installing KB2689311-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2689311-x64.msu /quiet /norestart
    echo installing KB2693010-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2693010-x64.msu /quiet /norestart
    echo installing KB2698279-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2698279-x64.msu /quiet /norestart
    echo installing KB2703610-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2703610-x64.msu /quiet /norestart
    echo installing KB2715922-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2715922-x64.msu /quiet /norestart
    echo installing KB2725279-v2-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2725279-v2-x64.msu /quiet /norestart
    echo installing KB2727324-v2-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2727324-v2-x64.msu /quiet /norestart
    echo installing KB2728738-v2-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2728738-v2-x64.msu /quiet /norestart
    echo installing KB2751389-x64
    Wusa.exe \scripts\MSI\Hotfix_x64\Windows6.1-KB2751389-x64.msu /quiet /norestart
    pause
    Ideally this would look like:

    Code:
    For each .msu in the folder.
    Echo installing 
    wusa.exe  /quiet /norestart
    Repeat
    Can anyone help with turning my psudocode into reality please?

  2. #2


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,870
    Thank Post
    226
    Thanked 2,666 Times in 1,965 Posts
    Rep Power
    785
    This should do it...

    Code:
    @echo off
    cd /d "%~dp0"
    
    for /f "skip=1" %%A in ('dir /b *.msu') do (
    echo Installing Update "%%A" ...
    start "" /wait WUSA %%A /quiet /norestart > nul
    )
    
    echo.
    echo Updates are installed. Press any key to reboot.
    pause >NUL
    shutdown -r -t 0

  3. Thanks to Arthur from:

    RabbieBurns (27th November 2012)

  4. #3

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,521
    Thank Post
    1,333
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199
    thanks will give it a whirl in the morning

  5. #4

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,521
    Thank Post
    1,333
    Thanked 469 Times in 306 Posts
    Blog Entries
    6
    Rep Power
    199
    Works great. Thanks

SHARE:
+ Post New Thread

Similar Threads

  1. simple bash for loop script
    By RabbieBurns in forum Scripts
    Replies: 24
    Last Post: 5th August 2009, 02:07 PM
  2. URGENT: Need software for scanning computers for software installed on them
    By DAckroyd in forum Network and Classroom Management
    Replies: 8
    Last Post: 19th March 2009, 11:13 AM
  3. Replies: 19
    Last Post: 30th January 2009, 12:06 AM
  4. NSS 9 - tutor PCs need setup for every user that logs on.
    By Halfmad in forum Network and Classroom Management
    Replies: 4
    Last Post: 23rd August 2007, 03:16 PM
  5. I think it's time for new servers
    By dezt in forum Wireless Networks
    Replies: 16
    Last Post: 11th June 2007, 10:54 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •