1.

Solve : Regasm.exe from command line?

Answer»

Hi there

In my batch file i have the following code

%1 having a parameter as serverA

for %%x in (\\%1\c$\test1\entities\*.dll) do
\\%1\c$\WINDOWS\system32\regsvr32.exe /s %%x >>"file.log"

\\%1\c$\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe "\\%1\c$\test1\entities\function.dll" /codebase >>"file.log"

2 questions really

On the file.log i'm not getting any information displayed about those vb6.dlls that are registered. how do i go about getting this written

My second question is when i try to register function.dll which is a .NET dll using the regasm.exe i GET Flags="Unmanaged Code" error. Not sure whether this is a .NET error or a DOS SYNTAX error. can u please advice?

regards

Quote

for %%x in (\\%1\c$\test1\entities\*.dll) do
\\%1\c$\WINDOWS\system32\regsvr32.exe /s %%x >>"file.log"

ELIMINATE the /s switch. This will allow the message box text to presumably get redirected to the log file.

Quote
\\%1\c$\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe "\\%1\c$\test1\entities\function.dll" /codebase >>"file.log"

Check out this link where you can set the SecurityPermissionAttribute in the source code.

Good luck. Thanks for the response
That was very helpful of you Quote from: Sidewinder on December 16, 2009, 04:58:16 PM
Eliminate the /s switch. This will allow the message box text to presumably get redirected to the log file.

This response was in error. It's true the /s switch and redirection are mutually exclusive, however redirection only works for the STDOUT datastream which is generally found in DOS or NT command line programs. Regsvr32 is a Windows program that probably uses a Windows function to format it's output to a window.

Further testing showed that even errorlevels are always zero, whether the registration fails or succeeds. Consider trying one of the Windows Scrpt Languages where you can run regsvr32 externally from the script, wait on return,  and check the return code.

Sorry for any confusion.  regsvr32 shows it's output VIA Messagebox.

However, it does return an Exit code.

For example- I created the following script to check:

Code: [Select]echo off
regsvr32 /s C:\windows\system32\vbscript.dll
echo errorlevel is %ERRORLEVEL%
regsvr32 /s nonexistent.dll
echo errorlevel is %ERRORLEVEL%

when I run as a non-admin, I get:

Quote
errorlevel is 5
errorlevel is 3

5 is the windows error code for "permission denied" and 3 is the windows error code for "file not found". When I run as an administrator, I get:

Quote
errorlevel is 0
errorlevel is 3

so, regsvr32 returns an error level that is either 0 (for success) or a windows error code. Quote from: BC_Programmer on December 17, 2009, 03:14:04 PM
so, regsvr32 returns an error level that is either 0 (for success) or a windows error code.

It's a bit ODD. When I ran regsvr32 from the command line, then checked the return code, it always came up zero whether it was successful or not. When run from from a batch file, I got the same results as BC.

Oh well, at least the OP has a method to run his script.



Discussion

No Comment Found