Showing posts with label for programmers. Show all posts
Showing posts with label for programmers. Show all posts

Friday, March 25, 2011

How to Register Many DLLs/OCXs at Once

It is sometimes necessary to register a COM or ActiveX library. As far as you know, it is easy to perform it with help of Regsvr32 utility by Microsoft. But it is hard to type the name of library to be registered each time when you need to register a lot of them. It's really easier to copy all needful files to a single folder and then register them all with help of really simple script:
for %%i in (c:\DLL\ActiveX\*.dll) do regsvr32 %%i
for %%i in (c:\DLL\ActiveX\*.ocx) do regsvr32 %%i
Please note that you can register even remote files
for %%i in (\\192.168.102.184\DLL\*.dll) do regsvr32 %%i
for %%i in (\\192.168.102.184\DLL\*.ocx) do regsvr32 %%i
Hope you'll find this example useful.

Friday, February 11, 2011

Merging Sources with Help of Batch Scripting

Batch files are exteremely useful for programmers. Developers can use batch scripting to automate boring jobs like making builds and packaging software. And not only for this - for example, to merge the existing dozens of script files to the single one. Here is the example of script that will help you to merge many JavaScript files placed in the same folder into the single script file. You can easily change this script with the help of Dr.Batcher, an advanced batch files editor.
@echo off
SET NewFile=cpfunct.js
cd \cpfunct\
@echo.>%NewFile%
for %%i in (*.js) do COPY /B %NewFile%+%%i %NewFile%
move %NewFile% ..\%NewFile%

It is useful to store the current version of the resulting JS in top of the file. Here is code that automatically reads and increments the version of the script before merging all files:

@echo off
setlocal
set /p vers=
for /f "tokens=2 delims==" %%i in ("%vers%") do set /a ver=%%i+1
1>main.tmp (
echo var vers=%ver%
more +1 result.js
)
del result.js
for %%i in (*.js) do copy /b main.tmp+%%i main.tmp
ren main.tmp result.js

Have any ideas about further enhancements? Don't hesitate to post your comments or send your suggestions to us!

Translate