locked
batch file will not run properly help please! RRS feed

  • General discussion

  • I am trying to create a windows batch script that will allow me to deploy preparation updates for Windows 7 64 bit but the script will not launch properly. I have all of the files inside of the same folder and I am attempting to extract the files then install them through dism when I launch it normally the files extract but dism does not launch correctly, when I run as administrator the files will not extract and dism exits with code 2. What am I doing wrong?

    expand -F:* .\Windows6.1-KB3135445-x64.msu .\ 
    timeout 2
    DISM.exe /online /Add-Package /PackagePath:.\Windows6.1-KB3135445-x64.cab 
    expand -F:* .\Windows6.1-KB3050265-x64.msu .\ 
    timeout 2
    DISM.exe /online /Add-Package /PackagePath:.\Windows6.1-KB3050265-x64.cab 
    expand -F:* .\Windows6.1-KB3065987-v2-x64.msu .\ 
    timeout 2
    DISM.exe /online /Add-Package /PackagePath:.\Windows6.1-KB3065987-v2-x64.cab 
    expand -F:* .\Windows6.1-KB3102810-x64.msu .\ 
    timeout 2
    DISM.exe /online /Add-Package /PackagePath:.\Windows6.1-KB3102810-x64.cab 
    expand -F:* .\Windows6.1-KB3138612-x64.msu .\ 
    timeout 2
    DISM.exe /online /Add-Package /PackagePath:.\Windows6.1-KB3138612-x64.cab 
    expand -F:* .\Windows6.1-KB3161608-x64.msu .\ 
    timeout 2
    DISM.exe /online /Add-Package /PackagePath:.\Windows6.1-KB3161608-x64.cab 
    expand -F:* .\Windows6.1-KB3161664-x64.msu .\ 
    timeout 2
    DISM.exe /online /Add-Package /PackagePath:.\Windows6.1-KB3161664-x64.cab 
    pause
    
    • Changed type Bill_Stewart Wednesday, August 17, 2016 6:35 PM
    • Moved by Bill_Stewart Wednesday, August 17, 2016 6:36 PM This is not "fix/debug/rewrite my script for me" forum
    Thursday, July 14, 2016 3:43 PM

All replies

  • Here's how to look up an error code:


    PS C:\> net helpmsg 2
    
    The system cannot find the file specified.
    


    -- Bill Stewart [Bill_Stewart]

    Thursday, July 14, 2016 3:52 PM
  • Yes but all of the files are there. I don't understand why its not working.
    Thursday, July 14, 2016 4:24 PM
  • I would recommend not trying to script updates and use something like WSUS instead.

    -- Bill Stewart [Bill_Stewart]

    Thursday, July 14, 2016 4:31 PM
  • It depends on who you are running the script as.  When you select "Run As Administrator" are you running it as yourself (meaning you are an administrator on the machine) or entering in an account in the UAC prompt?

    If you are running this script as a different account, it is likely that that account cannot see/access the files.  This is especially true when using mapped drives as the user running the script might not have the drive mapped like the user you are signed in does.

    Easy way to check this is to sign in as the administrator user account you are trying to use and see if it can access the files referenced in the script.

    Thursday, July 14, 2016 4:44 PM