Avatar of concordit
concordit asked on

VB login script to install software, but detect if its installed already...

I am trying to create a login script in my windows 2003 active directory domain, I would like it to install a software package, but before installing I would like it to detect if its installed already. Can some point me to VB script reference to help me with this, or perhaps send me a script that was made already.

I assume the the script would just look for a registry key or the presence of a file to see if the application is installed already?
Active Directory

Avatar of undefined
Last Comment

8/22/2022 - Mon

how about this
If Exist "C:\Program Files\whatever\whatever.exe" Exit
EXAMPLE of RegistryKeyExists 
' If RegistryKeyExists("HKLM","SOFTWARE\Microsoft\Updates\Windows XP\SP3\KB885887","FileList") = True Then 
'     WScript.Echo "True" 
' Else 
'     WScript.Echo "False" 
' End If 
the function's code:
Function RegistryKeyExists(LNGHKEY, strKey, strSubkey)
   Const HKLM = &H80000002
   Const HKCR= &H80000000T
   Const HKCU = &H80000001
   Const HKUSERS = &H80000003
   RegistryKeyExists = False
   Dim reg, aSubkeys, s, hkroot
   If LNGHKEY = "HKLM" Then hkRoot = HKLM
   If LNGHKEY = "HKCU" Then hkRoot = HKCU
   If LNGHKEY = "HKCR" Then hkRoot = HKCR
   Set reg = GetObject("WinMgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
   reg.EnumKey hkroot, strKey, aSubkeys
   If Not IsNull(aSubkeys) Then
       For Each s In aSubkeys
           If lcase(s)=lcase(strSubkey) Then
               RegistryKeyExists = True
               Exit Function
           End If
   End If
End Function    

Open in new window


Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.