I have created a batch file that goes to a series of application directories and registers all dll and ocx files within them. If I open an elevated command prompt and change to a specific directory and type in the regsvr command manually it works fine. The batch file looks like it is trying to register each file, but they do not get registered. I have tried right clicking on it and tell it to run as administrator (the command window does not show "Administrator" in the title bar), but it doesn't register. If I open an elevated command window and try to run the batch file from there, it doesn't work either.
I have also tried putting the script file in c:\Windows\System32 and C:\Windows\SysWOW64 and nothing has worked.
I also read that the file needed to be ANSI instead of Unicode, but that didn't help either.
Is there some sort of command I can put on the line with regsvr that will force each one to be elevated? I don't want to make the user type all the commands in manually.
Here is my batch file:
chdir c:\program files (x86)\pfps
for /r %%i in (*.dll) do regsvr32 /s %%i
chdir DataManager
for /r %%i in (*.dll) do regsvr32 /s %%i
chdir ..\falcon
for /r %%i in (*.dll) do regsvr32 /s %%i
for /r %%i in (*.ocx) do regsvr32 /s %%i
chdir FVOverlays
for /r %%i in (*.dll) do regsvr32 /s %%i
chdir ..\..\FVImageryService
for /r %%i in (*.dll) do regsvr32 /s %%i
chdir ..\GarminGPSFeed
for /r %%i in (*.dll) do regsvr32 /s %%i
chdir ..\MapDataServer
for /r %%i in (*.dll) do regsvr32 /s %%i
chdir ..\SkyViewNG
for /r %%i in (*.dll) do regsvr32 /s %%i
for /r %%i in (*.ocx) do regsvr32 /s %%i
chdir ..\System
for /r %%i in (*.dll) do regsvr32 /s %%i
for /r %%i in (*.ocx) do regsvr32 /s %%i
The problem are the spaces in your path:
c:\program files (x86)\pfps
. Theregsvr32
command will separate on spaces and read that as multiple arguments.To allow spaces you have to use quotes:
leading to e.g.:
where the path to the file is handled as single argument for
regsvr32
.Why does:
chdir c:\program files (x86)\pfps
work with spaces and without quotes?It's explained here on ss64 about
cd/chdir
:But I recommend always using quotes for paths.