Batch file not reporting if installation is clean

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?
LVL 18
Alex GreenProject Systems EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michael PfisterCommented:
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..
0
Alex GreenProject Systems EngineerAuthor 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.
0
Alex GreenProject Systems EngineerAuthor Commented:
if not errlorlevel was spelt wrong, but it still isn't giving me a log.
0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Michael PfisterCommented:
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

0
Steve KnightIT ConsultancyCommented:
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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David Johnson, CD, MVPOwnerCommented:
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

0
Steve KnightIT ConsultancyCommented:
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
0
Steve KnightIT ConsultancyCommented:
Hmm can see you deleted your comment while I posted that, working now?
0
Alex GreenProject Systems EngineerAuthor 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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.