Discussion:
Retrieve installation path of a software using VBScript
(too old to reply)
A K Arun
2007-05-02 11:00:53 UTC
Permalink
Hi,

How can I get the installed location of a windows software using VBScript ?

Thanks in advance,
Arun
mayayana
2007-05-02 13:59:08 UTC
Permalink
There are two options. Neither is perfect, and both require
that the program is officially installed. One method,
if you know the executable name, is to look here:

HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths

Under the App Paths key will be a key named for the
EXE (ex.: "program.exe"). The default value in that key
should be the EXE path.

The other method is to check this key:

HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall

Each subkey here is a name of a program that shows
in the Uninstall window. But this method has even more
problems than the first:

1) The program must have a registered uninstaller. The installer
itself writes this key.

2) You must know the official name of the program.

3) The Windows Installer system messes up the operation
of this key. A program installed via MSI will use a CLSID for
a key name instead of using the program name. That means
that you have to enumerate all the keys if you really want to
use this method because the names of the Uninstall subkeys are
just not very useful. Something like "ABC Editor" *should*
have a key name the same as the program folder, but it might
be "Acme ABC Editor", or it might be "{1A34D....."


4) UninstallString and DisplayName are pretty much the
only values that a program needs to put here in order for
uninstall to work via Add/Remove Programs. And the uninstall
string does not necessarily point to the program folder. It
could point to, say, an uninstall EXE in the Windows folder.
Some programs will add a value like "InstallLocation" to
this key, but it's not necessary. To make things even more
confusing, Microsoft will add invalid entries here. For instance,
when they want to store an uninstall string but block uninstall,
they'll leave out the DisplayName value so that it doesn't
show up in Add/Remove Programs. Or they may list a program
that has no values at all in the key.
Post by A K Arun
Hi,
How can I get the installed location of a windows software using VBScript ?
Thanks in advance,
Arun
A K Arun
2007-05-02 15:37:18 UTC
Permalink
Thanks a ton for the explanation.

I did get your point there and I was able to get the VB script ready. The
main task which the script is to perform is take backup of a few dll and
executables from the 'bin' folder of a software. This task ought to be
performed when the product is uninstalled.

The script runs fine when its executed separately. However, when I add it as
a custom action to the uninstall operation, it copies the dll's but fails to
get the version information. I need the version information so that it can
be associated with the dll's being backed up.

I feel its happening because the uninstall thread removes the registry
entries before the custom action gets fired.

Some information about the software that ought to be uninstalled-
1. .NET application written in C#,VB
2. It gets officially installed.

Is there some way by which I can get the product information from the dll's
which get backed up ? I mean the version value which is present in the
properties of a dll, can a VB script retrieve that value ?

Am a bit confused at the moment on how to proceed on this.

Thanks,
Arun
Post by mayayana
There are two options. Neither is perfect, and both require
that the program is officially installed. One method,
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths
Under the App Paths key will be a key named for the
EXE (ex.: "program.exe"). The default value in that key
should be the EXE path.
HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
Each subkey here is a name of a program that shows
in the Uninstall window. But this method has even more
1) The program must have a registered uninstaller. The installer
itself writes this key.
2) You must know the official name of the program.
3) The Windows Installer system messes up the operation
of this key. A program installed via MSI will use a CLSID for
a key name instead of using the program name. That means
that you have to enumerate all the keys if you really want to
use this method because the names of the Uninstall subkeys are
just not very useful. Something like "ABC Editor" *should*
have a key name the same as the program folder, but it might
be "Acme ABC Editor", or it might be "{1A34D....."
4) UninstallString and DisplayName are pretty much the
only values that a program needs to put here in order for
uninstall to work via Add/Remove Programs. And the uninstall
string does not necessarily point to the program folder. It
could point to, say, an uninstall EXE in the Windows folder.
Some programs will add a value like "InstallLocation" to
this key, but it's not necessary. To make things even more
confusing, Microsoft will add invalid entries here. For instance,
when they want to store an uninstall string but block uninstall,
they'll leave out the DisplayName value so that it doesn't
show up in Add/Remove Programs. Or they may list a program
that has no values at all in the key.
Post by A K Arun
Hi,
How can I get the installed location of a windows software using VBScript
?
Post by A K Arun
Thanks in advance,
Arun
mayayana
2007-05-03 00:08:14 UTC
Permalink
I'm not too clear about exactly what you're doing.
For version number you can use:
FileSystemObject.GetFileVersion

But you mentioned a "custom action". Does that
mean you're trying to run a script in a Windows Installer
installation? If so, that's really a different issue. Doing
the job the script needs to do is a VBS issue, but setting
it up as part of an MSI install is an MSI issue. You
might try microsoft.public.platformsdk.msi for that.
Post by A K Arun
Thanks a ton for the explanation.
I did get your point there and I was able to get the VB script ready. The
main task which the script is to perform is take backup of a few dll and
executables from the 'bin' folder of a software. This task ought to be
performed when the product is uninstalled.
The script runs fine when its executed separately. However, when I add it as
a custom action to the uninstall operation, it copies the dll's but fails to
get the version information. I need the version information so that it can
be associated with the dll's being backed up.
I feel its happening because the uninstall thread removes the registry
entries before the custom action gets fired.
Some information about the software that ought to be uninstalled-
1. .NET application written in C#,VB
2. It gets officially installed.
Is there some way by which I can get the product information from the dll's
which get backed up ? I mean the version value which is present in the
properties of a dll, can a VB script retrieve that value ?
Am a bit confused at the moment on how to proceed on this.
Thanks,
Arun
Post by mayayana
There are two options. Neither is perfect, and both require
that the program is officially installed. One method,
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths
Under the App Paths key will be a key named for the
EXE (ex.: "program.exe"). The default value in that key
should be the EXE path.
HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
Each subkey here is a name of a program that shows
in the Uninstall window. But this method has even more
1) The program must have a registered uninstaller. The installer
itself writes this key.
2) You must know the official name of the program.
3) The Windows Installer system messes up the operation
of this key. A program installed via MSI will use a CLSID for
a key name instead of using the program name. That means
that you have to enumerate all the keys if you really want to
use this method because the names of the Uninstall subkeys are
just not very useful. Something like "ABC Editor" *should*
have a key name the same as the program folder, but it might
be "Acme ABC Editor", or it might be "{1A34D....."
4) UninstallString and DisplayName are pretty much the
only values that a program needs to put here in order for
uninstall to work via Add/Remove Programs. And the uninstall
string does not necessarily point to the program folder. It
could point to, say, an uninstall EXE in the Windows folder.
Some programs will add a value like "InstallLocation" to
this key, but it's not necessary. To make things even more
confusing, Microsoft will add invalid entries here. For instance,
when they want to store an uninstall string but block uninstall,
they'll leave out the DisplayName value so that it doesn't
show up in Add/Remove Programs. Or they may list a program
that has no values at all in the key.
Post by A K Arun
Hi,
How can I get the installed location of a windows software using VBScript
?
Post by A K Arun
Thanks in advance,
Arun
A K Arun
2007-05-03 11:01:04 UTC
Permalink
Hi,

Thanks again.
What follows is my VB script -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim absPath

absPath = WScript.ScriptFullName
MsgBox "SourcePath" & absPath
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Planning to build on this script once it succeeds at the uninstall.
When my software gets installed, this script gets copied to its 'bin'
folder. I have this script as a custom action that ought to be fired when
the product is uninstalled. However, on the uninstall it cribs. I also tried
to create WScript.Shell and tried using it instead of
WScript.ScriptFullName, but no use.

thanks,
Arun
Post by mayayana
I'm not too clear about exactly what you're doing.
FileSystemObject.GetFileVersion
But you mentioned a "custom action". Does that
mean you're trying to run a script in a Windows Installer
installation? If so, that's really a different issue. Doing
the job the script needs to do is a VBS issue, but setting
it up as part of an MSI install is an MSI issue. You
might try microsoft.public.platformsdk.msi for that.
Post by A K Arun
Thanks a ton for the explanation.
I did get your point there and I was able to get the VB script ready. The
main task which the script is to perform is take backup of a few dll and
executables from the 'bin' folder of a software. This task ought to be
performed when the product is uninstalled.
The script runs fine when its executed separately. However, when I add it
as
Post by A K Arun
a custom action to the uninstall operation, it copies the dll's but fails
to
Post by A K Arun
get the version information. I need the version information so that it can
be associated with the dll's being backed up.
I feel its happening because the uninstall thread removes the registry
entries before the custom action gets fired.
Some information about the software that ought to be uninstalled-
1. .NET application written in C#,VB
2. It gets officially installed.
Is there some way by which I can get the product information from the
dll's
Post by A K Arun
which get backed up ? I mean the version value which is present in the
properties of a dll, can a VB script retrieve that value ?
Am a bit confused at the moment on how to proceed on this.
Thanks,
Arun
Post by mayayana
There are two options. Neither is perfect, and both require
that the program is officially installed. One method,
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths
Under the App Paths key will be a key named for the
EXE (ex.: "program.exe"). The default value in that key
should be the EXE path.
HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
Each subkey here is a name of a program that shows
in the Uninstall window. But this method has even more
1) The program must have a registered uninstaller. The installer
itself writes this key.
2) You must know the official name of the program.
3) The Windows Installer system messes up the operation
of this key. A program installed via MSI will use a CLSID for
a key name instead of using the program name. That means
that you have to enumerate all the keys if you really want to
use this method because the names of the Uninstall subkeys are
just not very useful. Something like "ABC Editor" *should*
have a key name the same as the program folder, but it might
be "Acme ABC Editor", or it might be "{1A34D....."
4) UninstallString and DisplayName are pretty much the
only values that a program needs to put here in order for
uninstall to work via Add/Remove Programs. And the uninstall
string does not necessarily point to the program folder. It
could point to, say, an uninstall EXE in the Windows folder.
Some programs will add a value like "InstallLocation" to
this key, but it's not necessary. To make things even more
confusing, Microsoft will add invalid entries here. For instance,
when they want to store an uninstall string but block uninstall,
they'll leave out the DisplayName value so that it doesn't
show up in Add/Remove Programs. Or they may list a program
that has no values at all in the key.
Post by A K Arun
Hi,
How can I get the installed location of a windows software using
VBScript
Post by A K Arun
Post by mayayana
?
Post by A K Arun
Thanks in advance,
Arun
mayayana
2007-05-03 13:30:08 UTC
Permalink
As I tried to explain in the last post, that's not a VBScript
issue. Your script is fine, but it's not getting run. So
that's an issue with the uninstaller. You didn't even say
what the uninstaller is. I'm guessing that it's an MSI because
they have "custom actions". But whatever it is, your real
question is why the uninstaller is not running the script.
That depends on the uninstaller and how you configured
it. How could anyone here answer that question, especially
when they don't even know what you're using as an installer?

Personally, I think the Windows Installer (MSI) system has got
to be the worst fiasco Microsoft ever produced. And that's
quite a statement, when you think about it. Spot watches?
Zune? Passport? A 500 MB version of Office? No, I'd say
MSI is worse than any of them. (Well, maybe I'd make an
exception for Vista. I'm not sure. I've been fortunate not to
have to actually deal with Vista. :)
MSI is an incredibly complex, unnecessary mess.

A lot of people like Inno Setup, which is free, for installations.
You might try that if you're not happy with MSI or whatver it is
that you're using. I use my own rewrite of the VB6 installer and
I don't know much about using MSI for installations. Someone
here might know, but if you're using MSI then you really need
to ask in an MSI newsgroup.
Post by A K Arun
Thanks again.
What follows is my VB script -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim absPath
absPath = WScript.ScriptFullName
MsgBox "SourcePath" & absPath
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Planning to build on this script once it succeeds at the uninstall.
When my software gets installed, this script gets copied to its 'bin'
folder. I have this script as a custom action that ought to be fired when
the product is uninstalled. However, on the uninstall it cribs. I also tried
to create WScript.Shell and tried using it instead of
WScript.ScriptFullName, but no use.
thanks,
Arun
Post by mayayana
I'm not too clear about exactly what you're doing.
FileSystemObject.GetFileVersion
But you mentioned a "custom action". Does that
mean you're trying to run a script in a Windows Installer
installation? If so, that's really a different issue. Doing
the job the script needs to do is a VBS issue, but setting
it up as part of an MSI install is an MSI issue. You
might try microsoft.public.platformsdk.msi for that.
Post by A K Arun
Thanks a ton for the explanation.
I did get your point there and I was able to get the VB script ready. The
main task which the script is to perform is take backup of a few dll and
executables from the 'bin' folder of a software. This task ought to be
performed when the product is uninstalled.
The script runs fine when its executed separately. However, when I add it
as
Post by A K Arun
a custom action to the uninstall operation, it copies the dll's but fails
to
Post by A K Arun
get the version information. I need the version information so that it can
be associated with the dll's being backed up.
I feel its happening because the uninstall thread removes the registry
entries before the custom action gets fired.
Some information about the software that ought to be uninstalled-
1. .NET application written in C#,VB
2. It gets officially installed.
Is there some way by which I can get the product information from the
dll's
Post by A K Arun
which get backed up ? I mean the version value which is present in the
properties of a dll, can a VB script retrieve that value ?
Am a bit confused at the moment on how to proceed on this.
Thanks,
Arun
Post by mayayana
There are two options. Neither is perfect, and both require
that the program is officially installed. One method,
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths
Under the App Paths key will be a key named for the
EXE (ex.: "program.exe"). The default value in that key
should be the EXE path.
HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
Each subkey here is a name of a program that shows
in the Uninstall window. But this method has even more
1) The program must have a registered uninstaller. The installer
itself writes this key.
2) You must know the official name of the program.
3) The Windows Installer system messes up the operation
of this key. A program installed via MSI will use a CLSID for
a key name instead of using the program name. That means
that you have to enumerate all the keys if you really want to
use this method because the names of the Uninstall subkeys are
just not very useful. Something like "ABC Editor" *should*
have a key name the same as the program folder, but it might
be "Acme ABC Editor", or it might be "{1A34D....."
4) UninstallString and DisplayName are pretty much the
only values that a program needs to put here in order for
uninstall to work via Add/Remove Programs. And the uninstall
string does not necessarily point to the program folder. It
could point to, say, an uninstall EXE in the Windows folder.
Some programs will add a value like "InstallLocation" to
this key, but it's not necessary. To make things even more
confusing, Microsoft will add invalid entries here. For instance,
when they want to store an uninstall string but block uninstall,
they'll leave out the DisplayName value so that it doesn't
show up in Add/Remove Programs. Or they may list a program
that has no values at all in the key.
Post by A K Arun
Hi,
How can I get the installed location of a windows software using
VBScript
Post by A K Arun
Post by mayayana
?
Post by A K Arun
Thanks in advance,
Arun
Loading...