Implement log and perhaps reboot "yes or no" featu

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
kpropell
Posts: 14
Joined: 24 Aug 2009 10:11

Implement log and perhaps reboot "yes or no" featu

#1 Post by kpropell » 24 Aug 2009 10:26

Hi! Im writing this bat script to install 11 programs in silent mode...
What i don't know now, is how to log everything... im reading on choice and how to figure out "Do you want to reboot" - yes - no.. ect.. but I can't figure out what to do about the logging.. the *easy* way.

My "code" is like this:

@echo off & SetLocal

Set "SourcePath=%~0\.."
echo Starting installation of Adobe Reader...
start /wait adobereader.exe /sAll /rs /l /msi"/qb-! /norestart ALLUSERS=1 EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES"
echo Adobe Reader is installed... starting installation of Firefox
start /wait firefox.exe -ms
echo Firefox is installed... starting installation of Java Runtime
start /wait java.exe /qn ADDLOCAL=ALL SYSTRAY=0 EULA=0 IEXPLORER=1 JAVAUPDATE=0 MOZILLA=1 AUTOUPDATECHECK=0 JU=0 REBOOT=ReallySupress
echo Jave Runtime is installed... starting installation of VLC
start /wait vlc.exe /L=1044 /S /NCRC
echo VLC is installed... starting installation of 7zip
start /wait 7zip.exe /S
echo 7zip is installed... starting installation of internet plugins
start /wait flashfirefox.exe /S
start /wait flashie.exe /S
start /wait air.exe -silent
start /wait shockwave.exe /S
start /wait silverlight.exe /q
start /wait wmpplugin.exe
echo All is installed - reboot the machine!
***soon to come: log and reboot now yes-now.

is it possible to do a logging of each install in a single line of code?
Im thinking of
blablaapp is installed (and where)
blablaapp is installed (and where)
ect...

Thanks!

ldrechsler
Posts: 5
Joined: 24 Aug 2009 15:56

#2 Post by ldrechsler » 24 Aug 2009 16:38

If you need screen output and a log file, I would approach it this way...

Code: Select all

set InstallLog=C:\Install.log

set App=Adobe Reader
echo Starting installation of %App%...
start /wait adobereader.exe /sAll /rs /l /msi"/qb-! /norestart ALLUSERS=1 EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES"
echo %App% is installed.
call :LOGGING

set App=Firefox
echo Starting installation of %App%...
start /wait firefox.exe -ms
echo %App% is installed.
call :LOGGING
.
.
.
goto EOF

:LOGGING
echo %date:~4%-%time:~0,8% Starting installation log...
echo %App% was successfully installed >> %InstallLog%
goto EOF

:EOF


In the :LOGGING area, the variable expansion just makes the log file easier to read.

kpropell
Posts: 14
Joined: 24 Aug 2009 10:11

#3 Post by kpropell » 25 Aug 2009 04:13

Thank you Idrechsler

That logging method was good! :) Perhaps I wasn't to clear of what I needed tho.

The output I'm looking for is: (I do know I can just find out beforehand where all the files go and hardcode it in.. but is there a way to track files being installed and log it?

Log.txt:
Adobe Reader was successfully installed! It's files are installed in C:\Program Files\Adobe\Adobe Reader\
Firefox was successfully installed! It's files are installed in C:\Program Files\Mozilla Firefox\
.
.
.

Something like that :) Will check the programs own logging features. I know Java has a /*log switch*

And when I'm on it. Is it also possible to log this?:

CMD.exe regedit someregfile.reg

Say i want a txt file with the contest of someregfile.reg + that it registered successfully.

Thanks!

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#4 Post by avery_larry » 25 Aug 2009 09:21

The logging part -- that's all up to you and the install programs I think. Nothing to do with a dos batch file (again, I think that's the case).

for the regedit -- probably the closest you'll come is checking the errorlevel after the command:

regedit -s c:\yourfile.reg
if errorlevel 1 (
echo Something went wrong
) else (
echo Successful
)

OR you could use the reg command and actually export the relevant registry and do a compare -- that's a lot more work, though.

kpropell
Posts: 14
Joined: 24 Aug 2009 10:11

#5 Post by kpropell » 25 Aug 2009 12:10

Thank you!
At first I used reg add HKLM\Software\whereever but it was easier code with regedit -s hurrah.reg like you said.
Just hoped that regedit had something like xcopy.
xcopy a.exe "%windir%" > C:\ log.txt or something like that...

Anyway I will figure a way. Log is not that important, I just like to have a report. And btw, batch scripting is fun!:D Reminds me of my endless days in linux and bash. This is making windows twice as fun!

Post Reply