|
Answer» There are 100's of dll in a folder and I want to run regsvr32 on all those dlls. How can I do that? Please help.
Thanks.after searching on net for a while about vbscript, I am able to write the following the script which solves my problem:
Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder("D:\MyFolder") 'point to your directory Set fc = f.Files set shellObj = CreateObject("WScript.Shell") Dim cnt cnt = 0
For Each objFile In fc If fso.GetExtensionName(objFile) = "dll" then shellObj.Run "regsvr32 /s " & objFile cnt = cnt+1 End If Next Wscript.echo("Total dlls found and registered = " & cnt)
curious if such things can be done through batch files ALSO. I am new to both vbscript and batch files.
Thanks.This would be the batch code equivalent:
Code: [Select]@echo off set cnt=0 for %%v in (D:\MyFolder\*.dll) do ( regsvr32 /s "%%v" call set cnt=%%cnt%%+1 ) echo Total dlls found and registered = %cnt%
Both batch code and VBScript have their uses. Generally I think you'll find batch code underpowered and a bit CRYPTIC (six months from now will you remember what %%v represents?).
VBScript can be a bit wordy and much work takes place in functions with positional parameters (six months from now will you remember the parameter order for the instr function?)
VBScript combined with HTML code can create front-end GUIs for even the most boring of scripts. Batch code is strictly command line.
Both are good tools to know. If you find yourself doing repetitive computer chores, scripting is a fine way to automate them.
Thanks for the reply. It does the work but the only difference is in the output of count. It gives output as: Total dlls register = 0+1+1+1+1+0+.... and says you do the bloody math yourself
Anyway, thanks.
Vivek.
PS: I may not remember what %%v STANDS for even after 1 month but I can always bookmark this page and will visit it whenver in doubt.If you're gonna do arithmetic you have to tell the interpreter:
Code: [Select]@echo off set cnt=0 for %%v in (D:\MyFolder\*.dll) do ( regsvr32 /s "%%v" call set /a cnt=%%cnt%%+1 ) echo Total dlls found and registered = %cnt%
Of course the DIY method works too.
|