I want to register few dll's using regsvr32
command in powershell.
I have created a foreach command to do it. In this case, some dll's might fail to register and I want to log each dll status in a log file.
This is what I have created so far
$dllfiles = @("1.dll","2.dll","3.dll","4.dll")
$dllfiles | ForEach {regsvr32 /s $_}
You need to run the command in cmd
for it to set $?
and $LASTEXITCODE
correctly:
$dllfiles | % {
& cmd /c regsvr32 /s $_
if ($?) {
"$_ registered correctly."
} else {
"Registration of $_ failed. ($LASTEXITCODE)"
}
}
[http://huddledmasses.org/register-dll-calling-regsvr32-without-messageboxes-in-powershell/] (page was apparently removed by the author)