Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I use an .inf file to copy a dll from a .cab to a specific folder and then register it?

910 views
Skip to first unread message

Rich

unread,
Nov 4, 2004, 12:34:59 AM11/4/04
to
I'd like to include foo.dll in a cab file. Upon the user downloading
my .cab file, I'd like to copy foo.dll from the .cab to a specific
folder (i.e., "C:\Program Files\MyFolder") and then register the dll.

Say my .inf file, which is included in my .cab file, looks like this:

;installation information sections
[DestinationDirs]
InstallFilesSection = -1, "C:\Program Files\MyFolder"

[Add.Code]
foo.dll=foo.dll

;source location for specified platform version
[foo.dll]
file-win32-x86=thiscab
FileVersion=1,0,0,0
clsid={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
RegisterServer=yes

The dll gets downloaded and registered all right, but it does not get
put into "C:\Program Files\MyFolder" as I'd like. As per the
documentation, files in the [Add.Code] section cannot be put in just
any location. The DestDir key can be used to specify that the file be
copied to either the \Windows directory, the \Windows\System directory
or the \Cache directory (the latter is the default).

Fine, suppose I change the .inf file to look like this:

[version]
signature="$CHICAGO$"
AdvancedINF=2.0

;installation information sections
[DestinationDirs]
InstallFilesSection = -1, "C:\Program Files\MyFolder"

[DefaultInstall]
CopyFiles=InstallFilesSection
RegisterDlls=RegisterMyDll

;files to be copied to the user's machine
[InstallFilesSection]
foo.dll=foo.dll

;source location for specified platform version
[foo.dll]
file-win32-x86=thiscab
FileVersion=1,0,0,0
clsid={xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

[RegisterMyDll]
-1,"C:\Program Files\MyFolder",foo.dll,1

If I right-click on the .inf file and select "Install", everything
works like a charm. foo.dll is copied to "C:\Program Files\MyFolder"
and is registered.

However, if I use this inf in my cab and then download the cab from my
website, foo.dll is copied to the right place, but it is not
registered. I could manually register it via the setting of
individual registry keys, but I prefer to use the built in
registration mechanism (i.e., the call to DllRegisterServer). I tried
adding RegisterServer=yes to the foo.dll section above, but that
didn't work.

Any ideas? Any recommended reading on the topic? The information I
found on msdn wasn't helpful.

Thanks!

name

unread,
Nov 5, 2004, 2:42:28 AM11/5/04
to
The inf file does only what is in the cab file.

There are MS cab files whose contents can only
be registerd properly manually.

---------------------

"C:\Program Files\MyFolder"

Hard coded destinations, I doubt it.

--------------

pseudo :

Call shell.Run('regserver32.exe pathName.extension")


"Rich" <hank...@hotmail.com> wrote in message
news:293839c3.04110...@posting.google.com...

mayayana

unread,
Nov 5, 2004, 9:57:11 AM11/5/04
to
I've made installers by making a self-executing zip (SFX)
with a VBScript inside. On my system, at least,
setting the command line of the SFX to the name of
the script file will run the script when the SFX is run.
So assuming that you set the SFX to unload in %TEMP%
and set your command line as "setup.vbs", then you've got
a single EXE installer.
Setup.vbs can then do the Registry settings, call RegSvr32,
and move files as needed.

--
_____________________________

mayayX...@mindYYspring.com
For return email remove XX and YY.
_____________________________


Rich <hank...@hotmail.com> wrote in message
news:293839c3.04110...@posting.google.com...

Rich

unread,
Nov 5, 2004, 4:49:13 PM11/5/04
to
Hi,

First off, thanks for the reply. Unfortunately, while I am an adept
C++ developer (or so I like to think! ;) ) I am new to the
installation process in general and .inf files in particular. As such
I am having trouble following your reply. Inline reponses to your
response are below...

> The inf file does only what is in the cab file.

I'm not sure what that means. I understand that the inf file, which
is embedded in the cab file, can read and copy files from within that
cab file. It can also reference files located elsewhere by providing
a url. In any case, the dll I'm attempting to copy and register is
embedded in the cab file.

>
> There are MS cab files whose contents can only
> be registerd properly manually.

Meaning in my case I can only register my file properly manually? I
hope not. Then I have to maintain two bits of registration
information, one in my C++ code for the dll and the other in the inf
file. I'd much rather call the C++ method via regsvr32.


> ---------------------
>
> "C:\Program Files\MyFolder"
>
> Hard coded destinations, I doubt it.
>

Meaning it's not possible to copy files to hardcoded destinations? Is
there a non-hardcoded way of specifying a non-system directory? I know
that using the CopyFile command can indeed copy to hardcoded
destinations because I've done it. The problem is that the
RegisterDLLs section is never executed. The only way I seem to be
able to register via an inf embedded in a cab is to use the [Add.Code]
section and specify RegisterServer=yes. But in that case my files are
being put in a directory I don't want them in.

> --------------
>
> pseudo :
>
> Call shell.Run('regserver32.exe pathName.extension")
>

Are you saying make a vbscript call to run a shell command? Is that
something that would be part of my inf file or in a seperate file? I
couldn't find anything in the inf help files on msdn that indicated I
could run scripts either directly in the inf or in a seprate file.
How would I go about doing that?

My apologies for the extensive reply and my apparent dimwittedness!
Thanks again for your response!

Rich

Rich

unread,
Nov 6, 2004, 1:19:55 AM11/6/04
to
"mayayana" <mayaXX...@mindYYspring.com> wrote in message news:<bxMid.4319$Gm6...@newsread3.news.atl.earthlink.net>...

> I've made installers by making a self-executing zip (SFX)
> with a VBScript inside. On my system, at least,
> setting the command line of the SFX to the name of
> the script file will run the script when the SFX is run.
> So assuming that you set the SFX to unload in %TEMP%
> and set your command line as "setup.vbs", then you've got
> a single EXE installer.
> Setup.vbs can then do the Registry settings, call RegSvr32,
> and move files as needed.
>

Thanks for the reply.

Sounds like a promising alternative to the inf/cab file download.
Which tool do you use to create your SFX files? InstallShield?

mayayana

unread,
Nov 6, 2004, 9:21:46 AM11/6/04
to
I think that I misunderstood your original post.
I thought you just wanted a script-based install option
for a DLL - something that people would be deliberately
downloading and running to do the update. So what
I suggested was just a self-executing zip file.

On re-reading your post it sounds like you want
to load an ActiveX control through IE as a way to
update your already-installed software with a new DLL.

Do you realize that the loading of ActiveX in IE is intended
only for webpage components that don't access the system?
Using that method to install software, not requiring user
approval, is really a back door method that verges on an attack.
It would be surprising if MSDN had any info. about using a
webpage ActiveX control method to install software.

(Frankly, it makes me all the more happy that I don't
use IE, knowing that you can force install a DLL to the
folder of your choice!)

--
_____________________________

mayayX...@mindYYspring.com
For return email remove XX and YY.
_____________________________
Rich <hank...@hotmail.com> wrote in message
news:293839c3.04110...@posting.google.com...

name

unread,
Nov 7, 2004, 4:08:29 AM11/7/04
to
"Do you realize that the loading of ActiveX in IE is intended
only for webpage components "

That is not correct.

------------

ActiveX is an inplementation of ole32.dll.


========================================

You are throwing out the kid with the bathtub and water.


"mayayana" <mayaXX...@mindYYspring.com> wrote in message

news:_55jd.1840$_J2....@newsread2.news.atl.earthlink.net...

mayayana

unread,
Nov 7, 2004, 7:47:32 PM11/7/04
to
I meant ActiveX in webpages. It sounds like
he's trying to install his software by embedding
it as an ActiveX control in a webpage.
--
_____________________________

Rich

unread,
Nov 9, 2004, 6:24:58 PM11/9/04
to
Inline comments below...

> I think that I misunderstood your original post.
> I thought you just wanted a script-based install option
> for a DLL - something that people would be deliberately
> downloading and running to do the update. So what
> I suggested was just a self-executing zip file.

Actually, you're right that is precisely what what I want. I have an
IE toolbar that I'd like distribute. I'd like a user to go to my
company's site, click "install toolbar" and have the toolbar installed
automatically, or as automatic as possible.

The installation of an IE toolbar is essentially the same as the
installation of an ActiveX control. All you need to do is download
the file and register it (manually via regsvr32 or as I was hoping,
automatically via internet component download).

This particular toolbar is more involved than the average activeX
control though because along with the toolbar dll, it will require
several supporting dlls. That's why I'd like to have my own
directory. It seems the cleanest way to do it. Moreover, some code
in those supporting dlls will have to be run intially in order for the
toolbar to work properly. (I didn't really address this issue in my
original post.)

Additionally, I'd like to be able to periodically update the toolbar,
either with the toolbar dll itself or updates to the supporting dlls.
I'd prefer that this part happen quietly, but maybe that's asking too
much.

Sounds like a self-extracting installation exe is what I'm going to
want. Do you use install shield? At first blush it didn't seem to do
what I needed to do, but I think that's just because I haven't delved
into the details as yet. It seems pretty powerful if you have the
time to learn the various features. Are there any other installation
packages you could recommend? (Unfortunately I can't use the Package
and Deployment Wizard because my dll is written in C++).

>
> On re-reading your post it sounds like you want
> to load an ActiveX control through IE as a way to
> update your already-installed software with a new DLL.

Sort of. I as mentioned above, I will want to do that in the future.

>
> Do you realize that the loading of ActiveX in IE is intended
> only for webpage components that don't access the system?

To be honest, I didn't think it through. That makes perfect sense. I
was blinded by the requirement to make the download as invisible as
possible.


> Using that method to install software, not requiring user
> approval, is really a back door method that verges on an attack.

Ah, but the user does approve the install. Either they have approved
it implicitly via their IE security settings or they have set up IE to
require approval of an activeX control's certificate before
downloading and installing the control. Either way, the approval is
there. In essence it isn't much different then downloading an install
program and running it. True, the install program itself can be
authenticated (as with MD5 with a lot of open source stuff), but
that's the same idea as a third party validated certificate. In any
case, a lot of people unwisely keep their security settings low and
consequently probably could get hacked with an automatic activeX
control installation.

> It would be surprising if MSDN had any info. about using a
> webpage ActiveX control method to install software.

Installing an ActiveX control is installing software. You're copying
a file to the harddrive and updating the registry - if that's not
installing software I don't know what is. ;)

>
> (Frankly, it makes me all the more happy that I don't
> use IE, knowing that you can force install a DLL to the
> folder of your choice!)

Well... I figured out how to copy files to a folder of my choice and
register dlls, but not both at the same time! I have a feeling
there's a way. In any case some damage can definitely be done to the
unsuspecting user. You could for example use an unsigned ActiveX
control to wreak havoc on the registry or point the startup key to
point at an exe that you've included in your download to be run the
next time the user reboots. Then the sky's the limit! Of course, the
sky's the limit with a an self-install exe as well.

Having said all that, your point is well taken. I'm obviously using
the wrong method for what I'm trying to do.

Thanks again for your comments. They've given me insight and have
pointed me in the right direction I think. Apologies for my usual
long-winded response!

mayayana

unread,
Nov 9, 2004, 8:03:07 PM11/9/04
to
> Apologies for my usual
> long-winded response!

It could just be thought of as thorough.

I don't know much about installers. I use VB6
with my own version of the PDW for software.
(And I put that stuff inside an SFX to create
a one-file installer.)
Many people recommend Inno Setup but I
don't know anything about it.
I guess you could still use a script inside an
SFX but that might be a bit hokey for such an
involved package.

Rich

unread,
Nov 10, 2004, 11:37:49 AM11/10/04
to
"mayayana" <mayaXX...@mindYYspring.com> wrote in message news:<fNdkd.6351$_J2....@newsread2.news.atl.earthlink.net>...

Great! I'll look into those options. Thanks for the recommendations.

p.s. I don't use IE either. I am an avid Mozilla fan!

Craig Miles

unread,
Nov 17, 2004, 4:54:25 PM11/17/04
to
Hi,

Perhaps you could help me :-)
I'm completely new to inf files.
I have a CAB with some files in it that I want put at a specific location.
None
of these files is actually an ActiveX control.
How can I get IE to trigger the download of the CAB and install the files?

I tried adding a dummy dll to the CAB. Then in the javascript it creates a
reference to it.
This downloads the CAB but everything is put into the cache folder - not
where I want it.

The inf files I've experimented with work fine if I run it manually.

Thanks,
Craig Miles


"Rich" <hank...@hotmail.com> wrote in message

news:293839c3.0411...@posting.google.com...
> Inline comments below...

Rich

unread,
Nov 18, 2004, 6:42:46 PM11/18/04
to
Hi Craig,

To download and copy files via a cab file do the following:

Note, the files will not be registered nor can they be from this newly
created directory. At least I haven't found a way to do this yet.

1) Create a GUID (Visual Studio ships with an application called
guidgen.exe that will generate one for you). Let's say your guid is
ABCDABCD-1234-ABCD-ABCD-123456789012.

2) Create an .inf file that looks like the following:
[version]
signature="$CHICAGO$"
AdvancedINF=2.0

;installation information sections
[DestinationDirs]
InstallFilesSection = -1, "C:\MyDir"

[DefaultInstall]
CopyFiles=InstallFilesSection

;files to be copied to the user's machine
[InstallFilesSection]

mydll.dll=mydll.dll
myexe.exe=myexe.exe

;source location for specified platform version

[mydll.dll]
file-win32-x86=thiscab
FileVersion=1,0,0,0
clsid={ABCDABCD-1234-ABCD-ABCD-123456789012}

[myexe.exe]
file-win32-x86=thiscab
FileVersion=1,0,0,0
clsid={ABCDABCD-1234-ABCD-ABCD-123456789012}

3) Put mydll.dll, myexe.exe and myinf.inf (the above inf file) into a
cab file. I use Microsoft's Cab SDK. Using the cabarc utility in the
Cab SDK, the command would be:

cabarc n mycab.cab mydll.dll myexe.exe myinf.inf.

4) Sign the cab file. This is optional but if you don't do it some
users might not be able to download your application unless they
change their IE security settings. Again, you can use the Cab SDK to
get this done.

Signing requires a certificate that is verified by a 3rd party such as
Verisign. The cab sdk provides a temporary certificate you can use
for testing. It's not really suitable for a serious distribution
however.

To make a temporary unverified certificate with the Cab SDK, type the
following at a command prompt:

MakeCert -sk myNewRootKey -r -ss myNewRoot

Then to sign your cab file:

SignCode -s myNewRoot mycab.cab

You can check the signing by typing the following:

ChkTrust mycab.cab

This will pop up the temporary certificate.

Don't forgeat that when you download the Cab SDK you'll have to either
put the exes you'll be using (i.e., MakeCert, cabarc, SignCode and
ChkTrust) in the directory where your cab file is *or* set your system
path variable to include the directory where the cabsdk binaries are
located.

5) On your download webpage include the following Object tag:

<OBJECT CODEBASE="http://.../mycab.cab#version=1,0,0,0"
CLASSID="clsid:ABCDABCD-1234-ABCD-ABCD-123456789012">
(if the cab file is in the same directory as the html file that
contains this object tag, you can omit the http:// path and just have
mycab.cab. Otherwise, specify the full path (i.e.,
CODEBASE="http://www.myurl.com/mycab.cab#version=1,0,0,0")

Note that all this will only work for IE clients. If someone
navigates to your page with another browser (Firefox, Safari, etc.)
the download will not occur.

More info can be found on msdn:
http://msdn.microsoft.com/workshop/delivery/download/overview/entry.asp

Good luck!
Rich


news:<uQTcCAP...@TK2MSFTNGP11.phx.gbl>...

0 new messages