Microsoft update msu silent mode batchfile - batch-file

I have the MSU for Win7AndW2K8R2-KB3134760-x64, which includes updates for PowerShell 5.0
I have a batchfile with the following to run the MSU in silent mode, but when I run it, it brings up the CMD window, then closes fast.
#echo off
start /wait ".\Win7AndW2K8R2-KB3134760-x64.msu" /quiet /norestart

Try this
#echo off
start "" /wait "Win7AndW2K8R2-KB3134760-x64.msu" /quiet /norestart

Related

MSI installer does not install when executed from a batch file

I am currently creating an improvised installer for a cople software packages. To do this I have to install a couple MSI packages first before doing a couple file operations.
To install an MSI package I am using the following command:
start /wait msiexec /i "Myinstaller V2.1.msi" /qb
This command works and installs the package instantly and witout any problems via CMD.
But when I put this command in my batch file and execute it as an administrator, I get the following error:
This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package
What cold be the problem? Using the same command via the console works flawlessly, only the batch file throws the error...
EDIT: I have also tried the /a parameter in order to install it as an administrator and it does not work either. Full command in batch file:
start /wait msiexec /qn /a "Myinstaller V2.1.msi"
EDIT2: I just realized that it only does not work when I start the batch file with Right click > Run as administrator
When I open a console with administrative rights and start my batch file it works for some reason...
Is there a way to make it work with the Right click > Run as administrator method?
SOLUTION: Thanks to RGuggisberg's answer I now know that the directory changes once the file is executed as an administrator. With a small change the installer gets fired up as an admin and works perfectly starting the installer from a relative path in the same directory:
#echo off
pushd %~dp0
start /wait msiexec /i "Myinstaller V2.1.msi" /qb
pause
I've now also implemented a feature to detect wether or not the installation fails or not:
#echo off
pushd %~dp0
start /wait msiexec /i "Myinstaller V2.1.msi" /qb
if %ERRORLEVEL% EQU 0 echo SUCCESSFULL
if NOT %ERRORLEVEL% EQU 0 echo MyProgram installation FAILED
pause
The current directory changes when you run as administrator. If you want to prove that to yourself, see this post
Difference between "%~dp0" and ".\"?
Include the full path to your filename and it will work.

running MSU not working

#echo off
start /wait wusa.exe %~dp0Win7AndW2K8R2-KB3134760-x64.msu /quiet /norestart
I have a .bat file with the above code. The file is located in \wds\e$\Shared\DeploymentBuild\Applications\Microsoft WMF 5.0.
The problem is, when I run it, it brings up the "Windows Update Standalone Installer" window and it won't do a silent install.
I have a copy of the same .bat file in my local computer, and it works fine without any issues. Please help me figure this out.
Thank you,
Tony
Start by changing your batch file accordingly:
#echo off
if not exist "%~dp0Win7AndW2K8R2-KB3134760-x64.msu" (
Echo= The MSU file isn't here!
Timeout -1 >Nul
Exit/B)
wusa.exe "%~dp0Win7AndW2K8R2-KB3134760-x64.msu" /quiet /norestart

Using PSEXEC to invoke a batch script on a remote machine won't launch Firefox

I am having the following issue:
Using PSEXEC, I remote into a machine to execute a batch script that is saved there, but the last line doesn't execute (it wont open Firefox .. the Firefox process shows up but the GUI doesn't launch).
However, if I go to the remote machine and double-click the batch file it works just fine.
Here is the command that I run locally:
psexec -u USER -p PASSWORD \\REMOTE_SERVER -d cmd.exe /c "C:\Users\MY-REMOTE-MACHINE\Desktop\windows_setup.bat"
Here are the contents of that batch script:
taskkill /f /im "iexplore.exe" /t
taskkill /f /im "chrome.exe" /t
c:\Windows\SysWow64\TaskKill /f /im "iexplore.exe" /t
c:\Windows\SysWow64\TaskKill /f /im "chrome.exe" /t
start "" "C:\Users\MY-REMOTE-MACHINE\AppData\Local\Mozilla Firefox\firefox.exe"
Note: I have also tried replacing the last line with start firefox ... same exact issue. It only works if I open the batch script directly from the target machine.

Run openvpn.exe, FreeFileSync.exe, then close command prompt

I am trying to write a batch file that connects to an OpenVPN profile, runs a FreeFileSync batch file, then exits.
cd "C:\Program Files\OpenVPN\config"
openvpn.exe --config synology.ovpn
"C:\Program Files\FreeFileSync\FreeFileSync.exe" "C:\Users\MrPeanut\Desktop\Sync.ffs_batch"
taskkill /f /im openvpn.exe
exit
It connects to my OpenVPN server. However, at this point, I'm still in the OpenVPN program, so the next command (FreeFileSync) can't run.
I know this is very basic, but I can't figure out how to run the next command while my OpenVPN program/connection is active.
You have to run it in the background, using START /B. This should work:
cd "C:\Program Files\OpenVPN\config"
START "" /B openvpn.exe --config synology.ovpn
"C:\Program Files\FreeFileSync\FreeFileSync.exe" "C:\Users\MrPeanut\Desktop\Sync.ffs_batch"
taskkill /f /im openvpn.exe
exit
I haven't tested it, but it should work fine.

windows update uninstall batch file

KB3114409 KB2825678 windows update patch files you may know that has caused many user to only be able to launch outlook in safe mode. that means i can not find anybody in outlook, anyway it is no good patch to me.
so i made batch file for our staff that is for uninstalling windows patch about KB3114409 KB2825678. it seems to be looking those file and uninstall. but if i have a look in installed update console, there is still remain those two.
i execute this batch file in administrator mode as well, but still same in.
#echo off
Wusa /KB:3114409 /Uninstall
Wusa /KB:2825678 /Uninstall
exit
i made it like that, but i still have those patches...
i use win7 64bit and using user mode, not administrator mode.
please any idea..?
Not sure if you really have everything on one line or if your post just turned out that way. This is what I use:
#echo off
start "" /b /wait wusa.exe /uninstall /kb:3114409 /quiet /norestart
start "" /b /wait wusa.exe /uninstall /kb:2825678 /quiet /norestart
To put all commands on one line you would need to separate them with &
but that makes it a bit harder to read. Also see WUSA /?
Its better to use MSIEXEC to remove this patch since its an "Office patch" and not for Windows.
Tutorial and script approach described at: http://blog.jocha.se/tech/uninstall-outlook-kb3114409

Resources