Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: regsitering all dll files inside a folder  (Read 23038 times)

0 Members and 1 Guest are viewing this topic.

vivek.m

    Topic Starter


    Starter

    regsitering all dll files inside a folder
    « on: August 11, 2008, 06:12:54 AM »
    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.

    vivek.m

      Topic Starter


      Starter

      Re: regsitering all dll files inside a folder
      « Reply #1 on: August 11, 2008, 06:59:18 AM »
      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.

      Sidewinder



        Guru

        Thanked: 123
      • Experience: Familiar
      • OS: Other
      Re: regsitering all dll files inside a folder
      « Reply #2 on: August 11, 2008, 09:25:16 AM »
      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.

       8)
      To every complex question there is a simple answer and it is wrong…

      - H.L. Mencken

      vivek.m

        Topic Starter


        Starter

        Re: regsitering all dll files inside a folder
        « Reply #3 on: August 11, 2008, 10:09:54 PM »
        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  :D

        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.

        Sidewinder



          Guru

          Thanked: 123
        • Experience: Familiar
        • OS: Other
        Re: regsitering all dll files inside a folder
        « Reply #4 on: August 11, 2008, 10:18:26 PM »
        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.  ;D
        To every complex question there is a simple answer and it is wrong…

        - H.L. Mencken