Log output of regsvr32 command.

  • Thread starter Thread starter Hetal
  • Start date Start date
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!!
 
"Hetal" <hetal.a.kapadia@gmail.com> wrote in message
news:ded64686-dbdc-46ef-ac51-e9fb2c128e9b@d4g2000prg.googlegroups.com...
>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.
 
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.
 
"Hetal" <hetal.a.kapadia@gmail.com> wrote in message
news:26c504bd-38fd-4199-b8ec-2e3144066b5f@s8g2000prg.googlegroups.com...
> 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!)
 
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

"Hetal" <hetal.a.kapadia@gmail.com> wrote in message
news:26c504bd-38fd-4199-b8ec-2e3144066b5f@s8g2000prg.googlegroups.com...
> 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 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.

"3c273" <nospam@nospam.com> wrote in message
news:fke7h20vfg@enews5.newsguy.com...
>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
>
 
You're welcome.
Louis

"Hetal" <hetal.a.kapadia@gmail.com> wrote in message
news:be22d9b9-c1f1-4747-a8dc-d857c10b808e@s19g2000prg.googlegroups.com...
> This is exactly what i wanted to achieve. Thank you for all your help
> Louis.
>
> Hetal.
 
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

"Hetal" <hetal.a.kapadia@gmail.com> wrote in message
news:be22d9b9-c1f1-4747-a8dc-d857c10b808e@s19g2000prg.googlegroups.com...
> This is exactly what i wanted to achieve. Thank you for all your help
> Louis.
>
> Hetal.
 
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

"Pegasus (MVP)" <I.can@fly.com> wrote in message
news:%23rP0xwzQIHA.4752@TK2MSFTNGP05.phx.gbl...
> 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.
>
> "3c273" <nospam@nospam.com> wrote in message
> news:fke7h20vfg@enews5.newsguy.com...
> >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
> >

>
>
 
Here is a good way to test ErrorLevels:

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

"3c273" <nospam@nospam.com> wrote in message
news:fkehsd016rf@enews5.newsguy.com...
> 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
>
> "Pegasus (MVP)" <I.can@fly.com> wrote in message
> news:%23rP0xwzQIHA.4752@TK2MSFTNGP05.phx.gbl...
>> 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.
>>
>> "3c273" <nospam@nospam.com> wrote in message
>> news:fke7h20vfg@enews5.newsguy.com...
>> >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
>> >

>>
>>

>
>
 
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.
 
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.
 
*** See below.

"Hetal" <hetal.a.kapadia@gmail.com> wrote in message
news:c367f83d-0784-40c7-9125-7b5e6d3380aa@i29g2000prf.googlegroups.com...
>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
> >=0 satisfies and return true.


*** 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".

> 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.
 
Back
Top