Link to home
Create AccountLog in
Avatar of TangoGirl

asked on

How to create auto-installer to register DLL on user Windows PCs

I need to find the most elegant solution for auto-installing a DLL (including registering it) on a user's PC. This would be invoked thorugh the user clicking a link (e.g. myDLL.exe).

All the target systems will be Windows: NT, 2000, XP or Vista.

I've looked at a few open source installers (like SEAU) and don't have time/budget to get InstallShield or Wise today. Is there a way perhaps using Microsoft SDK that's straightforward, or creating an MSI?

This particular issue is a brand new foray for me, so go easy :)

Avatar of RubenvdLinden

An easy and cheap way is to create a small batch file to do the job.
In the next example, I will copy your DLL to the Common Files\TangoGirl (probably in C:\Program Files) folder and register it:

@echo off
md "%CommonProgramFiles%\TangoGirl"
copy myDLL.DLL "%CommonProgramFiles%\TangoGirl"
regsvr32 "%CommonProgramFiles%\TangoGirl\myDLL.DLL"

Save this file as install.bat and copy it to the installation directory where your DLL resides.
Now just run it to install.

I hope this helps!
your best bet and by far your easiest bet is a simple batch file:

dll installer.bat
xcopy "<location of dll>" "<location you want the DLL to be in" /y /r
regsvr32 "<location of dll which has been copied>"

replace <location of dll> with the source location (a shared location on a network or within the same directory the bat file will run from)

replace <location you want the dll to be in> with the destination of the dll (system32 directory)

replace <location of dll which has been copied> with the same location as above

This will copy the dll to whichever location you want it to go to and then register it


xcopy "\\server1\dll\mydll.dll" "c:\windows\system32\" /y /r
regsvr32 "c:\windows\system32\mydll.dll!"

Avatar of Alan Huseyin Kayahan
   Hi TangoGirl
         Create a folder and copy the dll into it. Lets say that its xxx.dll
         Create a batch file with following commands in it

         copy xxx.dll c:\%windir%\system32
         regsvr32 xxx.dll

        As you double-click that bat file, dll will be installed and registered. You can share that folder and install from other clients

lol ruben, you beat me to it!!
LOL, indeed! But it's nice to know everyone agrees with me ;-)
Avatar of TangoGirl


sounds along the right lines... but how would I make this available via a web page - i.e. I can't link to the .bat file
..oops :)

I was assuming that you can't just link to a .bat file from a hyperlink?

Can you zip the file and offer it as a download on your website?
you will be able to link to the bat file, it will prompt the users to download the file and open it, once opened it will run.

So you will need to make sure that wherever the users will be downloading the bat file to, they will be able to access the UNC path when it opens :)
It works in an intranet environment; if the product is intended for external customers, your best bet is to offer it as a zip file.
I'm trying to make it as easy as possible for our non-tech customers. So thought exe was the best bet, rather than giving complex install instructions. WIll run some testing on the BAT now - cheers guys.
Avatar of RubenvdLinden

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I thought about a self-extracting file, but was missing the BAT bit :) Thanks Ruben will give this a try.
So... just to recap so I understand the process...

- create batch file with install commands
- create self-extracting archive containing DLL & BAT (with instruction to run BAT after extracting)

That is correct.
just literally: run install.bat ?
it'll have to be relative, right, so how will i determine the correct variable for common program files - i.e.

run %CommonProgramFiles%??\myinstall_directory\install.bat

i think i'm nearly there...!
Most self-extractors automatically assume that the working directory of the program to run should be the directory where the files are to be extracted. In that case, running install.bat should be enough to get things done.

If it doesn't, there is probably a simple solution:
You should be able to specify a default output directory for the self-extractor. Specify %TEMP%
Now, change the copy statement in install.bat like this:

copy "%TEMP%\myDLL.DLL" "%CommonProgramFiles%\TangoGirl"

I hope this helps
that's could be a solution i think, as it's having a problem running the command following extraction.

My other issue is not having admin rights to the program files dir of my own machine, which I can safely assume will also happen with lots of my users.

So I'm going for c:\myinstalldir\ instead. Do you foresee any issues with this? And is there a more elegant way of referencing this using environment vars, as I realise hard-coding c: is a risky strategy?
You could use %SYSTEMDRIVE% to find the disk where Windows resides.
I would recommend %USERPROFILE% though (this will return e.g. C:\Documents and Settings\TangoGirl).
However, installation without (at least some) admin rights is not possible. You might be able to copy the file to a user folder, but REGSVR32 really requires admin rights to register your DLL.
yes - I've just come a cropper with this one ;) Can only get as far as REGSVR32 and then that's it.

I don't think there's away around this..nnnggg!
The only thing you can do is to put an instruction on your website that the installation can only be performed by a system administrator or a user with administrative rights on the computer.

That way you can also specify the Common Files folder again, which is better. Come to think of it, it's not wise to store the DLL in a user folder; that way it will not be accessible for other users of the computer.
Yes fair comment, did cross my mind.

Thanks Ruben you've been incredibly helpful :)

Your welcome, I'm glad I could be of help!
related topic, & cheeky I know as I shoudl start a new q - but do you know of a simple way of determining whether the user has admin rights over their machine?

 I'm devising a test to determine this before I run the EXE to try to handle user experience a little better.