Log output of regsvr32 command.


H

Hetal

I have created a batch file that unregisters the old version of a dll,
copies the new version, and registers a new version of that dll on a
computer. The script works perfectly fine, but i would like to log the
output of this batch file to a text file.

I tried using the ">" redirector to create a file and the following
lines, i used ">>" redirector to append that file but the output from
regsvr32 does not log to the text file.

The bacth file that i created looks like this:
===============
@ECHO OFF
regsvr32 -u -s %windir%\System32\test.dll > C:\Test.txt
COPY \\server\sharedfolder\test.dll %windir%\System32\ >> C:\Test.txt
regsvr32 -s %windir%\System32\test.dll >> C:\Test.txt
===============

But the log file generated by this batch file only states:
===============
1 File(s) copied.
===============

Is there a way i can redirect the result of regsvr32 command to the
text file?

Thanks!!
 
Ad

Advertisements

P

Pegasus \(MVP\)

Hetal said:
I have created a batch file that unregisters the old version of a dll,
copies the new version, and registers a new version of that dll on a
computer. The script works perfectly fine, but i would like to log the
output of this batch file to a text file.

I tried using the ">" redirector to create a file and the following
lines, i used ">>" redirector to append that file but the output from
regsvr32 does not log to the text file.

The bacth file that i created looks like this:
===============
@ECHO OFF
regsvr32 -u -s %windir%\System32\test.dll > C:\Test.txt
COPY \\server\sharedfolder\test.dll %windir%\System32\ >> C:\Test.txt
regsvr32 -s %windir%\System32\test.dll >> C:\Test.txt
===============

But the log file generated by this batch file only states:
===============
1 File(s) copied.
===============

Is there a way i can redirect the result of regsvr32 command to the
text file?

Thanks!!

As far as I know, all output from regsvr32.exe is directed
to a dialog box (which you suppress with the -s switch), and
none to the console where it could be captured.
 
H

Hetal

Hi Pegasus.

Thank you for your response. Based on your inputs, it seems as if
there is no way to direct the result of regsvr32 to a log/text file.
The objective i am trying to achieve here is, i am deploying a newer
version of dll at domain level and i need to make sure that all
computers under that domain got updated.

I am not sure if the path that i have chosen to track this update is
efficient, but i would like to know if there is a better way to
achieve my objective?

Thanks.
 
P

Pegasus \(MVP\)

Hetal said:
Hi Pegasus.

Thank you for your response. Based on your inputs, it seems as if
there is no way to direct the result of regsvr32 to a log/text file.
The objective i am trying to achieve here is, i am deploying a newer
version of dll at domain level and i need to make sure that all
computers under that domain got updated.

I am not sure if the path that i have chosen to track this update is
efficient, but i would like to know if there is a better way to
achieve my objective?

Thanks.

I suspect that the best you can do is to create a log of
the machines where you applied the regsvr command,
e.g. like so:
@echo off
echo %date% %time% regsvr #1 applied on %ComputerName# >>
\\YourServer\SomeShare\Logs\regsrv.log
(this is a single long line!)
 
3

3c273

I don't see your original post but I think you are looking for something
like this. If you want to test for success, use errorlevel 0 instead.
-----begin-----
@echo off
regsvr32 /s mydllfile.dll
if errorlevel 3 echo "this failed" >> c:\test.txt
-----end-----
Louis
 
Ad

Advertisements

P

Pegasus \(MVP\)

I tried this before I gave my previous reply and found that
regsvr32 always returns an ErrorLevel of 0. Did you find
an instance when it does not? If so then please post it.
 
3

3c273

Now that I think about it, you should probably test for success (errorlevel
0) because there may be different exit codes for different failures and I
did not account for them. I actually put my batch file together by trial and
error.
Louis
 
3

3c273

This is very interesting. I should check more carefully before posting.
"regsvr32 invalid\path\to\file" and "regsvr32 path\to\invalid\dllfile" test
true for errorlevels 0, 1, 2, and 3. A successful registration tests true
for errorlevel 0 only. (As far as I know from limited testing.) Please post
back if you can explain this. From your previous posts, your knowledge of
batch files is much greater than mine, but I can usually hack something
together when I need it.
Louis
 
P

Pegasus \(MVP\)

Here is a good way to test ErrorLevels:

regsvr32 invalid\path\to\file
echo Error Level=%ErrorLevel%
 
Ad

Advertisements

H

Hetal

i was quizzed by this errorlevel thing too... i previously had below
statements in my batch file and when this piece of code used to
execute, it would always returns true even if dll registration fails.

=============
regsvr32 -u -s %windir%\System32\arview2.ocx
if ErrorLevel 0 echo "registered myfile.dll" >> c:\test.log
=============

I researched a bit online and figured that the "If" condition in line
2 above interprets as ErrorLevel >=0 instead of ErrorLevel = 0. So
even if regsvr32 return error code 2, the condition ErrorLevel >=0
satisfies and return true.

i changed the second line of my code as mentioned below and that
worked for me.
=============
if %ErrorLevel% NEQ 0 echo "failed registered myfile.dll" >> c:
\test.log
=============

Please refer the following link for further information on ErrorLevel.
I got all the information regarding errorlevel from this website.

http://www.robvanderwoude.com/errorlevel.html

Thanks,
Hetal.
 
H

Hetal

I was quizzed by this errorlevel thing too... i previously had below
statements in my batch file and when this piece of code used to
execute, it would always return true even if dll registration failed.

=============
regsvr32 -u -s %windir%\System32\arview2.ocx
if ErrorLevel 0 echo "registered myfile.dll" >> c:\test.log
=============

I researched a bit online and figured that the "If" condition in line
2 above interprets as ErrorLevel >=0 instead of ErrorLevel = 0. So if
regsvr32 return error code 2, the condition ErrorLevel >=0 is
satisfied and it returns true.

i changed the second line of my code as mentioned below and that
worked for me.
=============
if %ErrorLevel% NEQ 0 echo "failed registered myfile.dll" >> c:
\test.log
=============

Please refer the following link for further information on ErrorLevel.
I got information needed by me on ErrorLevel from this website.

http://www.robvanderwoude.com/errorlevel.html

Thanks,
Hetal.
 
P

Pegasus \(MVP\)

*** See below.

Hetal said:
i was quizzed by this errorlevel thing too... i previously had below
statements in my batch file and when this piece of code used to
execute, it would always returns true even if dll registration fails.

=============
regsvr32 -u -s %windir%\System32\arview2.ocx
if ErrorLevel 0 echo "registered myfile.dll" >> c:\test.log
=============

I researched a bit online and figured that the "If" condition in line
2 above interprets as ErrorLevel >=0 instead of ErrorLevel = 0.

*** This is correct.
So even if regsvr32 return error code 2, the condition ErrorLevel

*** Yes.
i changed the second line of my code as mentioned below and that
worked for me.
=============
if %ErrorLevel% NEQ 0 echo "failed registered myfile.dll" >> c:
\test.log
=============

*** You are now using a completely different approach. Your
*** initial approach was based on the statement
*** "if ErrorLevel" (without %!), which is a legacy DOS method.
*** Your current statement uses the environmental variable
*** %ErrorLevel%, which was introduced with WinNT or
*** perhaps with Win2000.
*** You could also write
*** if %ErrorLevel% GTR 0 or
*** if %ErrorLevel% GEQ 1
*** Use "if /?" to see the possible conditions for "if".
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top