Query a Windows Installer (MSI) using Powershell

This is just a quick example of how we can query a Windows Installer using Powershell code: $msiOpenDatabaseModeReadOnly = 0 $msiOpenDatabaseModeTransact = 1 $windowsInstaller = New-Object -ComObject windowsInstaller.Installer $pathToMSI = “C:\Users\xxxx\Desktop\AlkaneExample.msi” $database = $windowsInstaller.GetType().InvokeMember(“OpenDatabase”, “InvokeMethod”, $null, $windowsInstaller, @($pathToMSI, $msiOpenDatabaseModeReadOnly)) $query … Continue reading

Set Registry Key Permissions with Powershell

A useful script to set registry key permissions with Powershell.  This example gives full control to the built in Users group. $acl = Get-Acl “HKLM:\SOFTWARE\Example” $person = [System.Security.Principal.NTAccount]”BuiltIn\Users” $access = [System.Security.AccessControl.RegistryRights]”FullControl” $inheritance = [System.Security.AccessControl.InheritanceFlags]”ContainerInherit,ObjectInherit” $propagation = [System.Security.AccessControl.PropagationFlags]”None” $type = [System.Security.AccessControl.AccessControlType]”Allow” … Continue reading

Create Lnk Shortcut using VBScript

Dim objShell : Set objShell = CreateObject(“WScript.Shell”) Dim userProfileFolder : userProfileFolder = objShell.ExpandEnvironmentStrings(“%USERPROFILE%”) Dim desktopFolder : desktopFolder = userProfileFolder & “\Desktop” Dim programFilesFolder : programFilesFolder = objShell.ExpandEnvironmentStrings(“%ProgramFiles%”) Dim shortcutName : shortcutName = “Alkane Test” Dim shortcutDescription : shortcutDescription = “Alkane … Continue reading