Change Computer Icon title to include Computer Name and Username in Windows 7 [Updated 05-14-2012]

By | February 25, 2012
Share

Updated 2012-May-14: Found subinacl did not work on Windows 7 x64. Found superior working tool (SetACL.exe) from the following site: http://sourceforge.net/projects/setacl/files/.  I confirmed it worked and updated the script accordingly.

This sample script utilizes a Microsoft tool “subinacl.exe”. This can be downloaded and extracted using 7-zip or equivalent (http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=23510). It uses this tool to take ownership of a vital registry key. There are no other pre-requisites to support using this tool. It has been tested in SCCM 2007 and MDT 2010/2012.

'On Error Resume Next
'==========VARIABLE ASSIGNMENTS=========================
Dim objFSO, objShell, sCurPath, strFileName, strCommand
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Scriptpath WithOUT trailing Backslash
sCurPath = objFSO.GetAbsolutePathName(".")
oldsetACLPath = sCurPath & "\SetACL.exe"
objFSO.CopyFile oldsetACLPath, "C:\Windows\Temp\", True

'Copy setACL.exe to c:\windows\temp
If Not err.Number = 0 Then
	Wscript.Quit
End If
setACLPath = "C:\Windows\Temp\SetACL.exe"

'Quit script if setACE.exe is not found
If Not objFSO.FileExists(setACLPath) Then
	Wscript.Quit
End If

'Load up Default hive
strCommand = "cmd.exe /c reg load HKEY_USERS\defhive c:\Users\Default\NTUSER.DAT"
strRet = objShell.Run(strCommand, 0, True)

'Take ownership to Administrators of classes root CLSID
strCommand = "cmd.exe /c " & setACLPath & " -on HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D} -ot reg -actn setowner -ownr ""n:Administrators;s:n"""
strRet = objShell.Run(strCommand, 0, True)
If Not strRet = 0 Then
	Wscript.Echo "Error Occured when setting owner: " & strRet
End If

'Give full permissions to Administrators of classes root CLSID
strCommand = "cmd.exe /c " & setACLPath & " -on HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D} -ot reg -actn ace -ace ""n:Administrators;p:full"""
strRet = objShell.Run(strCommand, 0, True)
If Not strRet = 0 Then
	Wscript.Echo "Error Occured when setting permissions: " & strRet
End If

'Clear any setting stored in Default Hive
strRet = objShell.RegWrite("HKEY_USERS\defhive\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\", "")
strRet = objShell.RegWrite("HKEY_USERS\defhive\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\LocalizedString", "")
'Clear any setting stored in CurrUser Hive
strRet = objShell.RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\", "")
strRet = objShell.RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\LocalizedString", "")
'Set Desired settings in Classes Root to be pulled on reboot
strRet = objShell.RegWrite("HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\LocalizedString", "%USERNAME% on %COMPUTERNAME%", "REG_EXPAND_SZ")

'Unload Default hive
strCommand = "cmd.exe /c reg unload HKEY_USERS\defhive"
strRet = objShell.Run(strCommand, 0, True)

Updated Download Sample (x64):
ComputerIconTitleChangeWin7-v2.zip: https://panaconsulting.egnyte.com/h-s/20120514/a6f07ca00d5d4472

Note: If using x86, replace setACL.exe with x86 version from the developer’s website listed above.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.