VBScript to determine Root Drive

As per best practices we should not hard code the Root Drive in our package. If your package goes to multiple machines having different Root Drives, then you can use this simple VBScript in your package as Custom Action and it will set the Root Drive automatically for that machine.
This script picks up the Root Drive from where Program Files folder is installed.

Set oshell=CreateObject("Wscript.shell")
prog=oshell.ExpandEnvironmentStrings("%ProgramFiles%")
vletter=Split(prog,":")
dletter=vletter(0) & ":\"
session.property("ROOTDRIVE")=dletter

Comments

Popular posts from this blog

VBScript to change the proxy settings if disconnected from VPN

Apple Inc

How to make an MSI with some files compressed in Cabinet file and other uncompressed outside the MSI