Batch file not reporting if installation is clean

Alex
Alex used Ask the Experts™
on
This code isn't pushing the log files out for me, I'd like to to confirm if it's been successful or not in the file and it's not working. :(

@echo off
setlocal enabledelayedexpansion

set GUIDs=DDF96E66-E39B-4A69-B776-2DE49EBCAFBD D7D3F00A-638B-41DE-A2A3-FFC6EF034783 B1A6CB20-C032-4228-940F-AC3BC9BF6B3E 3EB41C0B-00EF-4C8B-9FF7-FF252E2F4E33 D8A08493-2F06-4EB2-A636-4392991981AB 
for %%a in (%GUIDs%) do (
     reg.exe query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{%%a}" >NUL 2>&1
      if not errorlevel 1 (
            echo Uninstalling %%a
            start "Uninstalling %%a" /wait msiexec.exe /X{%%a} /quiet
      )
)

:::8x8 VOD Latest Version Installation
::: Copy the latest version of the VOD to the path below and change the msi filename
start "Installing VOD" /wait msiexec.exe /i \\Domain.com\SYSVOL\domain.com\scripts\8x8\VOD_5_6_0.msi /qn
if not errlorlevel 1 echo %date% %time% %Computername% - Installation succeeded >> "\\fileserver\company Common\logs\InstallVOD.log"

::: Please wait for the time to finish

timeout 15

:::Reboot machine

shutdown /r /t 60

Open in new window


Any ideas?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Does the installation work?

Check if users have write permission to the share "\\fileserver\company Common" (share permisisons are read only by default when you create it) and to the folder "logs" in the share (NTFS permissions)

I'd rather use a different log for each computer, like \\fileserver\company Common\logs\InstallVOD_%COMPUTERNAME%.log
Just in case 2 computers install at the same time..
AlexSenior Infrastructure Analyst

Author

Commented:
Good point,

The installation is fine, but I want a log on if it installs or not, I'm running this with my admin account so should work fine, everyone has permission to this folder.
AlexSenior Infrastructure Analyst

Author

Commented:
if not errlorlevel was spelt wrong, but it still isn't giving me a log.
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Does it log when you remove if errorlevel 1 ?

echo %date% %time% %Computername% - Installation result: %ERRORLEVEL%>> "\\fileserver\company Common\logs\InstallVOD_%COMPUTERNAME%.log"

Open in new window

Commented:
After a quick look think the problem is START which creates another window to run the MSIEXEC, I think you will find that always returns 0.

start "Installing VOD" /wait msiexec.exe /i \\Domain.com\SYSVOL\domain.com\scripts\8x8\VOD_5_6_0.msi /qn
if not errlorlevel 1 echo %date% %time% %Computername% - Installation succeeded >> "\\fileserver\company Common\logs\InstallVOD.log"

Open in new window


So how about doing away with START command and just running the uninstall, then you will see the errorlevel, in fact why not record the errorlevel and success/failure code too if it helps?

msiexec.exe /i \\Domain.com\SYSVOL\domain.com\scripts\8x8\VOD_5_6_0.msi /qn
(if %errorlevel%==0 (
  echo %date% %time% %Computername% - Installation succeeded
) ELSE (
  echo %date% %time% %Computername% - Installation FAILED - %errorlevel%
)) >> "\\fileserver\company Common\logs\InstallVOD.log"

Open in new window

Top Expert 2016
Commented:
I agree remove the start since you will never get the errorlevel from the proces you start what you are getting is the errorlevel from the start and not the process that is started

@echo off
setlocal enabledelayedexpansion

set GUIDs=DDF96E66-E39B-4A69-B776-2DE49EBCAFBD D7D3F00A-638B-41DE-A2A3-FFC6EF034783 B1A6CB20-C032-4228-940F-AC3BC9BF6B3E 3EB41C0B-00EF-4C8B-9FF7-FF252E2F4E33 D8A08493-2F06-4EB2-A636-4392991981AB 
for %%a in (%GUIDs%) do (
     reg.exe query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{%%a}" >NUL 2>&1
      if not errorlevel 1 (
            echo Uninstalling %%a
          msiexec.exe /X{%%a} /quiet
      )
)

:::8x8 VOD Latest Version Installation
::: Copy the latest version of the VOD to the path below and change the msi filename
msiexec.exe /i \\Domain.com\SYSVOL\domain.com\scripts\8x8\VOD_5_6_0.msi /qn
if not errlorlevel 1 echo %date% %time% %Computername% - Installation succeeded >> "\\fileserver\company Common\logs\InstallVOD.log"

::: Please wait for the time to finish

timeout 15

:::Reboot machine

shutdown /r /t 60

Open in new window

Commented:
Take out the @echo off - does it show it running the msiexec command, it appears OK from here ...

Are you doing this with run-as-administrator assuming UAC is on?  The /qn option will fail silently if you don't run-as-admin, if you change it to /qb (or remove /q option altogether) and UAC prompts you to say "yes" then that will show it isn't being run as admin.

Steve

Commented:
Hmm can see you deleted your comment while I posted that, working now?
AlexSenior Infrastructure Analyst

Author

Commented:
Yeah it's working well, basically I took some of your code and then some of David's code and joined it and it's perfect.

Thank you very very much :D

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial