Wednesday, July 01, 2015

Citrix Receiver upgrade and double icon issue

I recently had to upgrade Citrix Receiver for one of my clients and I faced numerous issues during the install.
I had to enable SSO for Citrix Receiver and add a storefront URL so when the users launch Citrix Receiver they should be able to launch their apps store directly without going through login prompts and entering the url.

While Citrix Receiver can be installed with the following command:

CitrixReceiver.exe /silent /noreboot /includeSSON ENABLE_SSON=Yes ALLOWADDSTORE=N ALLOWSAVEPWD=S

And Store URL can be set in the ADM template of Citrix Receiver, however, you will need to uninstall the older version before you install the new one.

Other issues faced were for double icons which appeared on those users machines who had added an app store themselves in the previous version. When a new store was added through Group policy, it actually doubled the store and the icons.
The stores are created in the below registry key:
HKCU\Software\Citrix\Dazzle
When I removed this for the user and infact for all the users, it left behind dead icons in Start Menu, Desktop and in Citrix Receiver console. Also due to these dead icons, then I faced issues for Citrix stealing focus from all other applications.

Citrix suggests to use Citrix uninstall utility, but that works only when a logged on user runs it as an administrator which is rare in our environments.

I wrote following script to install, delete dead icons and remove the HKCU keys for all users of Citrix which are left behind.
You will Need:
1) Citrix Receiver
2) Receiver Cleanup Utility
to be in the same install  folder as these scripts.

Script 1

install.vbs

'Created: Piyush Nasa
'Date: 05-May-2015

Dim oExplorer
Dim oShell                   ' Windows Scripting Host shell
Dim oFSO                            ' File system object
Dim sCurDir, AppName, srd ' Script path
Dim sWinDir ' Windows root path
Dim scpf86, spf, strAppMsg, oEnv
dim strComputer, oReg, strKeyPath, strValueName, StringVal

'===========================================
' Main

'On Error Resume Next

Set oShell = CreateObject("WScript.Shell")

set oEnv = oShell.Environment("PROCESS")

oEnv("SEE_MASK_NOZONECHECKS") = 1

sCurDir = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\") - 1)

sWinDir = oShell.ExpandEnvironmentStrings ("%WinDir%")

const HKEY_LOCAL_MACHINE = &H80000002

'Check if previous version exists
'--------------------------------------

strComputer = "."

DIM fso  
Set fso = CreateObject("Scripting.FileSystemObject")

'Uninstall if anything left from Citrix
oShell.Run sCurDir & "\ReceiverCleanupUtility.exe /silent", 1, 1

'Uninstall Previous version

If (fso.FileExists("C:\ProgramData\Citrix\Citrix Receiver\TrolleyExpress.exe")) Then
  oShell.Run chr(34) & "C:\ProgramData\Citrix\Citrix Receiver\TrolleyExpress.exe" & chr(34) & " /Uninstall /Cleanup /silent", 1, 1
Else
  'Do Nothing
End If

'Uninstall if anything left from Citrix
oShell.Run sCurDir & "\ReceiverCleanupUtility.exe /silent", 1, 1

'Uninstall any Citrix Shortcuts left behind
oShell.Run sCurDir & "\DeleteShortcuts.vbs", 1, 1

'Uninstall Citrix keys in HKCU left behind
oShell.Run sCurDir & "\UninstallCitrixRegs.vbs", 1, 1

AppName = "Citrix Receiver 4.2.1"


' Install Citrix Receiver 4.2.1
oShell.Run sCurDir & "\CitrixReceiver.exe /silent /noreboot /includeSSON ENABLE_SSON=Yes ALLOWADDSTORE=N ALLOWSAVEPWD=S", 1, 1

oEnv.Remove("SEE_MASK_NOZONECHECKS")


'Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

'strKeyPath = "SOFTWARE\\Applications\CitrixReceiver"

'strValueName = "Installed"
'StringVal = 1

'oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
'oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,StringVal


Script 2.

DeleteShortcuts.vbs

On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wshShell    = WScript.CreateObject("WScript.Shell")
'initialize logging
strLogFile = wshShell.ExpandEnvironmentStrings("%TEMP%\CitrixReceiverShortcutClean.log.txt")
Set objLogFile = objFSO.OpenTextFile(strLogFile, 8, True)
objLogFile.WriteLine Now & ": Logging Initialized"
'get list of folders in C:\Users
Set objFolder = objFSO.GetFolder("C:\Users")
objLogFile.WriteLine Now & ": Got list of user folders under C:\Users"
For Each UserSubFolder in objFolder.SubFolders
 'search the users start menu for Citrix shortcuts
'msgbox UserSubFolder.Path
 objStartFolder = UserSubFolder.Path & "\AppData\Roaming\Microsoft\Windows\Start Menu"
'msgbox objStartFolder
 objLogFile.WriteLine Now & ": Searching folder: " & objStartFolder
 Set objSearchFolder = objFSO.GetFolder(objStartFolder)
 Set colFiles = objSearchFolder.Files
 For Each objFile in colFiles
     If InStr(objFile.Name, ".lnk") Then
  IsCitrixShortcut objSearchFolder.Path & "\" & objFile.Name
     End If
 Next
 ShowSubfolders objFSO.GetFolder(objStartFolder)
 ' now search the users desktop for Citrix shortcuts
 objStartFolder = UserSubFolder.Path & "\Desktop"
 objLogFile.WriteLine Now & ": Searching folder: " & objStartFolder
 Set objSearchFolder = objFSO.GetFolder(objStartFolder)
 Set colFiles = objSearchFolder.Files
 For Each objFile in colFiles
     If InStr(objFile.Name, ".lnk") Then
  IsCitrixShortcut objSearchFolder.Path & "\" & objFile.Name
     End If
 Next
 ShowSubfolders objFSO.GetFolder(objStartFolder)
Next
objLogFile.WriteLine Now & ": Script complete"
Sub ShowSubFolders(Folder)

    For Each Subfolder in Folder.SubFolders
        Set objFolder = objFSO.GetFolder(Subfolder.Path)
        Set colFiles = objFolder.Files
        For Each objFile in colFiles

     If InStr(objFile.Name, ".lnk") Then

  IsCitrixShortcut SubFolder.Path & "\" & objFile.Name
     End If
        Next
        ShowSubFolders Subfolder
    Next
End Sub

Sub IsCitrixShortcut(strShortcut)
'msgbox strShortcut
 ' CreateShortcut works like a GetShortcut when the shortcut already exists!
 Set objShortcut2 = wshShell.CreateShortcut(strShortcut)
' WScript.Echo "Target Path       : " & objShortcut2.TargetPath

'WScript.Echo "Full Name         : " & objShortcut2.FullName
'WScript.Echo "Arguments         : " & objShortcut2.Arguments
'WScript.Echo "Working Directory : " & objShortcut2.WorkingDirectory
'WScript.Echo "Target Path       : " & objShortcut2.TargetPath
'WScript.Echo "Icon Location     : " & objShortcut2.IconLocation
'WScript.Echo "Hotkey            : " & objShortcut2.Hotkey
'WScript.Echo "Window Style      : " & objShortcut2.WindowStyle
'WScript.Echo "Description       : " & objShortcut2.Description




 If (InStr(objShortcut2.WorkingDirectory,"Citrix") Or InStr(objShortcut2.TargetPath,"Citrix")) Then
 'msgbox "found citrix"
 objLogFile.WriteLine Now & ": Deleting PNAgent Shortcut: " & strShortcut
If objFSO.FileExists (strShortcut) Then
  objFSO.DeleteFile strShortcut,True
'msgbox "File Deleted"
Else
'msgbox "File not found"
End If
 End If
End Sub


Script 3
UninstallCitrixRegs.vbs

'On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

Const HKU = &H80000003

strComputer = "."
strKeyPath = "Software\Citrix"
strKeyPath1 = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
sName = "SiteName" ' Change this to site in your environment from which it starts and has common string

Set objRegistry = GetObject("winmgmts:\\" & _
    strComputer & "\root\default:StdRegProv")
Set wmi = GetObject("winmgmts:\\.\root\cimv2")
Set reg = GetObject("winmgmts:\\.\root\default:StdRegProv")

Set profs = wmi.ExecQuery("Select SID from Win32_UserProfile where SID like 'S-1-5-21%'")
For Each prof In profs
  key = prof.SID & "\Software\Citrix"
DeleteSubkeys HKU, key

  key1 = prof.SID & "\" & strKeyPath1

EnumerateKeys HKU, key1


' Call reg.DeleteKey(HKU, key) 'commented out for safety
Next
'End If



Sub DeleteSubkeys(HKU, strKeyPath)
    objRegistry.EnumKey HKU, strKeyPath, arrSubkeys

    If IsArray(arrSubkeys) Then
        For Each strSubkey In arrSubkeys
            DeleteSubkeys HKU, strKeyPath & "\" & strSubkey
        Next
    End If

    objRegistry.DeleteKey HKU, strKeyPath
End Sub

Sub EnumerateKeys(hive, key)
  'WScript.Echo key
  objRegistry.EnumKey hive, key, arrSubKeys
  If Not IsNull(arrSubKeys) Then
    For Each skey In arrSubKeys
      EnumerateKeys hive, key & "\" & skey
      t=(InStr(skey,"sName"))
      If (t=1) Then
      'MsgBox skey
      DeleteSubkeys hive, key & "\" & skey
      End If
     
    Next
  End If
End Sub

Tuesday, February 03, 2015

How to uninstall any version of Java

I wanted to uninstall Java from all the machines and install the latest one. There were sometimes multiple versions of Java which had to be removed. Some machines had both 32 bit and 64 bit Java versions. Here is the easiest batch script to uninstall any version of Java on the machine.
There were scripts available but they did not delete 64 bit versions of Java and some very old versions of Java. Hence I modified those scripts to meet my need.

set mycmd=reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s /f *java* for /f " usebackq delims={} tokens=2" %%i IN (`%mycmd%`) do ( msiexec /uninstall {%%i} /passive )
set mycmd=reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /s /f *java* for /f " usebackq delims={} tokens=2" %%i IN (`%mycmd%`) do ( msiexec /uninstall {%%i} /passive )

Sunday, May 18, 2014

VBScript to change the proxy settings if disconnected from VPN

When connected to VPN, user's IE proxy settings get changed and is forced by VPN.
Often the users might get disconnected from VPN while working from home and this does not revert back the proxy settings to the original one.
I have written a VBScript to change the proxy settings of the users. This script can be made a shortcut and then used.

'Script Created by Piyush Nasa
'Script to change Proxy settings for user if disconnected from VPN

Option Explicit
Dim valUserIn
Dim objShell, RegLocate, RegLocate1
Set objShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
valUserIn = MsgBox("If you have been disconnected from VPN and want to reset your proxy, click Yes and restart Internet Explorer",4,"Proxy Reset")
If valUserIn=vbYes Then
RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"
objShell.RegWrite RegLocate,"","REG_SZ"
RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"
objShell.RegWrite RegLocate,"0","REG_DWORD"

'Enable AutoDetect in the proxy by calling this sub
IEautomaticallydetect

MsgBox "Proxy is reset to AutoDetect"

else
'I do not want any proxy so I have disabled this, but if you want to set a proxy then you can use this.

'RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"
'objShell.RegWrite RegLocate,"xxxx.xxx.com:80","REG_SZ"
'RegLocate = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable"
'objShell.RegWrite RegLocate,"1","REG_DWORD"
MsgBox "Your Proxy is not changed."
End If
WScript.Quit



 SUB IEautomaticallydetect


 DIM sKey,sValue,binaryVal
 Dim oReg
 Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")    'For registry operations througout

 Const HKCU=&H80000001

 sKey = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections"
 sValue = "DefaultConnectionSettings"

 oReg.GetBinaryValue HKCU, sKey, sValue, binaryVal

'you can keep different values of this binary to have different options. 9 is just for Auto detect enable.
binaryVal(8) = 9

 oReg.SetBinaryValue HKCU, sKey, sValue, binaryVal
 end sub

Wednesday, May 15, 2013

Packaging Skype with Auto Update disabled

EDITED: I have edited this post on 30-Aug-2013 after some users comments that the given solution is not working. I have studied in depth the skype update process and created this solution for all. Please check below (Edited Section) for more information.

Recently while packaging Skype for enterprise version, I could not disable the Auto Updates and finally found a way to get rid of it.

You can get the latest version of Skype setup in MSI format from the following URL: http://download.skype.com/msi/SkypeSetup.msi or
http://www.skype.com/go/getskype-msi


There is no registry, file which can disable the Auto Update functionality of Skype. I searched in lots of forums and all said that it automatically prompts for update. So finally I decided to look in the MSI and find why and how it is doing it.

What I found was that Skype has an Updater.exe in the installation folder and it also creates a Skype Update service which points to this exe.
I just removed this service and updater.exe file from the skype msi package and it worked.
No need to do anything else. Just do this small part and you are done with removing the Auto Update in Skype.

Edited:
I have been asked and told by a lot of users that this is not working so I am adding a further solution which will definitely work without a doubt. I have mass deployed this and it has worked fine. For all the users who were getting the pop ups, this has fixed it.

You need to create a dummy SetupSkype.exe file and a Skypefix.vbs as below and add it to your INSTALLDIR (C:\Program Files\Skype\Phone\) of the package.

SkypeFix.vbs:
'==============================================
dim filesys, oShell
Set filesys = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")

des1 = oShell.ExpandEnvironmentStrings ("%Temp%")
sup = oShell.ExpandEnvironmentStrings ("%ProgramFiles%")
windir = oShell.ExpandEnvironmentStrings ("%Windir%")

destfile1= des1 & "\SkypeSetup.exe"
sourcefile1= sup & "\Skype\Phone\SkypeSetup.exe"

'Copy files

If filesys.FileExists(sourcefile1) Then

 a= filesys.CopyFile (sourcefile1, destfile1,True)

End If

oShell.Run windir & "\System32\Icacls.exe " & destfile1 & " /deny Everyone:D"

'=================================================

After this you need to create an Active Setup registry key which will run this vbs file for every user who logs off and logs in. After this there will be no upgrade issue.

This script works on the fact that SkypeSetup.exe gets downloaded from internet to %temp% folder of user and when it is downloaded, it starts prompting up for upgrade. I have created this file before hand in %temp% folder or replace the already existing one with this dummy file and then put a deny restriction to all the users on this file. So now a file cannot be downloaded to %temp% folder because there is already a file which cannot be deleted/replaced. Hence no more upgrade prompts.
I have created this solution by deeper understanding of Skype setup and upgrade.

Hope this tip will be helpful to you and let me know if it still does not work.

Tuesday, April 16, 2013

How to clear App-V Cache

This has become my favorite site today because one of the issue which I was facing in App-V while testing was because the App-V cache was not getting cleared.
I used one of the method used here and it worked for me.
I want to share this link with all and want to bookmark it for myself for future reference.

http://esense.be/33/2010/04/15/softgrid-clear-the-appv-cache/


In Summary, these are a few good options to start with:


First, get a list of all AppV applications:
sftmime query obj:app /short
Remove all applications from the cache:
sftmime.exe remove obj:app /global /complete
Remove a specific application from the cache:
sftmime.exe remove app:”applicationName” /complete


Hope your issues are solved with this as well.

Sunday, March 17, 2013

App-V with Java/JRE/JDK

It is very critical to understand how to handle installation of Java related applications in App-V environment.
While some are of the view that the application should be installed along with Java in the same bubble while some say that the Java version installed on the base machine can be used.

Here is how you can do both of these in a proper way:

1) Java installed locally on the machine: If Java is locally installed on the machine and you capture the App-V application, then you will see a hard coded entry in the registry. This basically points the App-V application to look for Java in this local machine location. If you upgrade your Java version from say 1.6.21 to 1.6.24, then you do not need to worry, however, if you do a major upgrade from 1.6.21 to 1.7.xx then you need to upgrade your App-V Application as well. You need to maintain the software library for all these applications and then upgrade them as part of Java Upgrade in the organization.

2) Java is installed as local copy inside App-V bubble: Java can also be installed as a local copy with your App-V application. There can be various reasons for doing this:
 a) Application is compatible only with a certain version of Java
 b) Application uses a higher version which is not locally installed.
 c) If Software manager do not want to upgrade the application every time Java gets updated.

In these cases a private copy of Java can be captured with App-V. However, there is a procedure for achieving this.
These steps will be helpful in doing this:

http://packagingguide.blogspot.com.au/2011/11/app-v-for-java-runtime-environment.html

Monday, February 25, 2013

Detection Method for MSU in Applications for SCCM 2012

In SCCM 2012 Applications you can have a detection method set for MSU with KB numbers.

You can use the Powershell or VBScript to do this. Here is an example of both.

Powershell Script:

get-hotfix | Where-Object {$_.HotFixID -match "KB981603"}

VBScript:

'Returns info if Windows 'KB981603'  in installed
' ----------------------------------------------------------'
Option Explicit

Dim objWMIService, strComputer
strComputer = "."

'Run the query
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")
 
Dim QFEs
Dim QFE
Set QFEs = objWMIService.ExecQuery ("Select * from win32_QuickFixEngineering where HotFixID like 'KB981603'")
For Each QFE in QFEs
    Wscript.echo "Update KB981603 was installed by " & QFE.InstalledBy & " on " & QFE.InstalledOn
Next
WScript.Quit

Thursday, February 14, 2013

VBScript to Delete Registrly key and all subkeys


This script has worked good for me and I would like to share with all.

Option Explicit

    Dim intHive
    Dim strComputer
    Dim strKeyPath, objRegistry

    Const HKEY_CLASSES_ROOT        = &H80000000
    Const HKEY_CURRENT_USER    = &H80000001
    Const HKEY_LOCAL_MACHINE    = &H80000002
    Const HKEY_USERS        = &H80000003
    Const HKEY_CURRENT_CONFIG    = &H80000005

    'On Error Resume Next

    strComputer            = "."
    intHive                = HKEY_LOCAL_MACHINE
 
    strKeyPath            = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ABC\XYZ"

    Set objRegistry        = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

    DelSubkeys intHive, strKeypath

    Set objRegistry        = Nothing

    Sub DelSubkeys(ByVal intRegistryHive, ByVal strRegistryKey)
        Dim arrSubkeys

        objRegistry.EnumKey intRegistryHive, strRegistryKey, arrSubkeys
        If IsArray(arrSubkeys) Then
            For Each strSubkey In arrSubkeys
                DelSubkeys intRegistryHive, strRegistryKey & "\" & strSubkey
            Next
        End If

        objRegistry.DeleteKey intRegistryHive, strRegistryKey
    End Sub

Wednesday, January 30, 2013

VBScript to Delete Folder and all SubFolders with files


Here is the VBScript which will delete all Folders and Subfolders with even have files in it.
It took me so many hours to find this perfect script and all credits go to Rob van der Woude and the original script is here: http://www.robvanderwoude.com/vbstech_folders_deltree.php
I just want to keep this for my reference and for everyone so that we all can save some time.


Option Explicit

Dim objFSO, objTempFolder, strTempFolder

Const TEMP_FOLDER = 2

Set objFSO        = CreateObject( "Scripting.FileSystemObject" )
Set objTempFolder = objFSO.GetSpecialFolder( TEMP_FOLDER )
strTempFolder     = objTempFolder.Path

DelTree strTempFolder, True


Sub DelTree( myFolder, blnKeepRoot )
' With this subroutine you can delete folders and their content,
' including subfolders.
' You can specify if you only want to empty the folder, and thus
' keep the folder itself, or to delete the folder itself as well.
' Root directories and some (not all) vital system folders are
' protected: if you try to delete them you'll get a message that
' deleting these folders is not allowed.
'
' Arguments:
' myFolder     [string]   the folder to be emptied or deleted
' blnKeepRoot  [boolean]  if True, the folder is emptied only,
'                         otherwise it will be deleted itself too
'
' Written by Rob van der Woude
' http://www.robvanderwoude.com
'
    Dim arrSpecialFolders(3)
    Dim objMyFSO, objMyFile, objMyFolder, objMyShell
    Dim objPrgFolder, objPrgFolderItem, objSubFolder, wshMyShell
    Dim strPath, strSpecialFolder

    Const WINDOWS_FOLDER =  0
    Const SYSTEM_FOLDER  =  1
    Const PROGRAM_FILES  = 38

    ' Use custom error handling
    On Error Resume Next

    ' List the paths of system folders that should NOT be deleted
    Set wshMyShell       = CreateObject( "WScript.Shell" )
    Set objMyFSO         = CreateObject( "Scripting.FileSystemObject" )
    Set objMyShell       = CreateObject( "Shell.Application" )
    Set objPrgFolder     = objMyShell.Namespace( PROGRAM_FILES )
    Set objPrgFolderItem = objPrgFolder.Self

    arrSpecialFolders(0) = wshMyShell.SpecialFolders( "MyDocuments" )
    arrSpecialFolders(1) = objPrgFolderItem.Path
    arrSpecialFolders(2) = objMyFSO.GetSpecialFolder( SYSTEM_FOLDER  ).Path
    arrSpecialFolders(3) = objMyFSO.GetSpecialFolder( WINDOWS_FOLDER ).Path

    Set objPrgFolderItem = Nothing
    Set objPrgFolder     = Nothing
    Set objMyShell       = Nothing
    Set wshMyShell       = Nothing

    ' Check if a valid folder was specified
    If Not objMyFSO.FolderExists( myFolder ) Then
        WScript.Echo "Error: path not found (" & myFolder & ")"
        WScript.Quit 1
    End If
    Set objMyFolder = objMyFSO.GetFolder( myFolder )

    ' Protect vital system folders and root directories from being deleted
    For Each strSpecialFolder In arrSpecialFolders
        If UCase( strSpecialFolder ) = UCase( objMyFolder.Path ) Then
            WScript.Echo "Error: deleting """ _
                       & objMyFolder.Path & """ is not allowed"
            WScript.Quit 1
        End If
    Next

    ' Protect root directories from being deleted
    If Len( objMyFolder.Path ) < 4 Then
        WScript.Echo "Error: deleting root directories is not allowed"
        WScript.Quit 1
    End If

    ' First delete the files in the directory specified
    For Each objMyFile In objMyFolder.Files
        strPath = objMyFile.Path
        objMyFSO.DeleteFile strPath, True
        If Err Then
            WScript.Echo "Error # " & Err.Number & vbCrLf _
                       & Err.Description         & vbCrLf _
                       & "(" & strPath & ")"     & vbCrLf
        End If
    Next

    ' Next recurse through the subfolders
    For Each objSubFolder In objMyFolder.SubFolders
        DelTree objSubFolder, False
    Next

    ' Finally, remove the "root" directory unless it should be preserved
    If Not blnKeepRoot Then
        strPath = objMyFolder.Path
        objMyFSO.DeleteFolder strPath, True
        If Err Then
            WScript.Echo "Error # " & Err.Number & vbCrLf _
                       & Err.Description         & vbCrLf _
                       & "(" & strPath & ")"     & vbCrLf
        End If
    End If

    ' Cleaning up the mess
    On Error Goto 0
    Set objMyFolder = Nothing
    Set objMyFSO    = Nothing
End Sub

Thursday, December 13, 2012

Permissions to registry using setacl

Recently I was trying giving permission to one of the registry hives with Subinacl, but it was not working despite all efforts and checking all the syntax and a lot of troubeshooting.

Then I came across another permission granting utility known as SetACL. It worked like a charm. So you can try using this utility is Subinacl fails.

You can download SetACL from http://helgeklein.com/download/

Here is an example to run SetACL to give registry permissions.

"SetACL.exe" -on "hkcr\Interface" -ot reg -actn setowner -ownr "n:Administrators"
"SetACL.exe" -on "hkcr\Interface" -ot reg -actn ace -ace "n:Users;p:full"


  • Object name (-on): This is the path to the object SetACL should operate on (file/directory/registry key/network share/service/printer).
  • Object type (-ot): What kind of object does the object name refer to: file or directory (file), registry key (reg), service (srv), printer (prn), network share (shr)?
  • Action (-actn): What should SetACL do with the object specified?

A lot more details and description can be found at this awesome site: http://helgeklein.com/setacl/documentation/command-line-version-setacl-exe/