Question

I have lots of dlls present inside a folder . I want to register all those dlls in a single shot by running one batch file , So that i dont have to register each and every dll one by one . Please help me in generating a batch file for it .

Thanks in advance .

Was it helpful?

Solution

Okay, this should work:

Code:

@echo off
pushd C:\...[path to file]
for /r %%a in (*.dll) do (
Rem Put the instance of the REG command you want to use here
Rem (refer to file as %%a)
Rem e.g. | REG add %%a

Echo Registering %%a . . .
)
popd
Echo.
Pause | Echo Registration Complete: Program will now Exit
Exit

Pretty much for /r performs a recursive search through the current dir (and sub-dirs).

Type for /? for more info or ask if you want further explanation.

Explanation:

In the above code all commands used followed by and explanation is below:

  • Echo - Displays a message on the screen.
  • @echo - Turns Echo to either on or off. Turning it off will suppress the console from displaying the prompt. That is, the user will not see what commands the batch file is executing, only what you tell the batch file to Echo and the output of any other commands used.
  • pushd - Changes the current directory command prompt searches in to the path specified (and stores the previous direcotry for convienience)
  • popd - Goes to the last directory in (in relation to pushd)
  • for /r - Executes the commands specified for each file in the current and sub directory's where the variable created (in this example %%a) is the name of the file
  • Reg - used to register
  • Rem - Remarks in a batch file : These lines are comments that are ignored
  • Pause - Waits for user input
  • Exit - Exits

Example:

@echo off
pushd c:\MyDll 
for /r %%a in (*.dll) do (
Reg /add %%a
Echo Registering %%a . . .
)
popd
Echo.
Pause | Echo Registration Complete: Program will now Exit
Exit
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top