Replace the icon lables “Computer” and “This PC” with something more useful.

This script will read the computers name and domain settings and rename the icon in the form computername.domain.local

This makes it much easier to be certain which desktop you are working on when using multiple remote RDP , mstsc connections.

I cant remember now where I found the “special” CLSID code for the registry entry, without that this wouldn’t be easy to do. It may have been on some of the technet discussions about this.

The registry functions were “borrowed” from http://ss64.com/vb/regwrite.html ,

It works on windows 7 and server 2008, server 2012 r2, windows 8.1

Windows 7 default name is “Computer”
Server 2008 default name is “Computer”
Windows 8.1 default name is “This PC”
Server 2012 default name is “This PC”

I found it annoying that a brand new server install was calling itself a PC 😉

I havent rolled it out in a domain anywhere (yet) but I like the idea of some standardised “useful” text there rather than the generic “computer” or “This PC”

'----------------------------------------------------------------------
' script to replace "Computer" name in windows explorer with the actual computer name.
'----------------------------------------------------------------------
 'dont use the computername from the environment as we want to query domain membership anyway.
 strOldName= readreg("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\")
 ' get network name if one is available "
 Dim WshNetwork
 Set WshNetwork = CreateObject("WScript.Network")
 dim sysinfo
 Set sysInfo = CreateObject("ADSystemInfo")
 strNewName = lcase( WshNetwork.ComputerName  )
 ' on some computers get an error if the domain is not defined. just use the computername then. 
 On error resume next
 strNewName = strNewName + "." + sysInfo.DomainDNSName
 on error goto 0
 strMyName = Wscript.ScriptFullName
 result = writereg("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\",strNewName,"REG_SZ")
 ' should do something with the result - ignore it for now. "

 strOldName= "This PC/My Computer label was """ + strOldName + """"
 strNewName = "Label now changed to """ + strNewName + """"
 nl=vbCRLF & vbCRLF 
 call wscript.echo(now & nl & strOldName & nl & strNewName & nl & strMyName )
 wscript.quit


' functions from  http://ss64.com http://ss64.com/vb/regwrite.html

Function WriteReg(RegPath, Value, RegType)
      'Regtype should be “REG_SZ” for string, “REG_DWORD” for a integer,…
      '”REG_BINARY” for a binary or boolean, and “REG_EXPAND_SZ” for an expandable string
      Dim objRegistry, Key
      Set objRegistry = CreateObject("Wscript.shell")

      Key = objRegistry.RegWrite(RegPath, Value, RegType)
      WriteReg = Key

end function

Function ReadReg(RegPath)
      Dim objRegistry, Key
      Set objRegistry = CreateObject("Wscript.shell")

      Key = objRegistry.RegRead(RegPath)
      ReadReg = Key
End Function

About Jeff Turner

Technical director of Nano Tera Network Solutions.
This entry was posted in Uncategorized. Bookmark the permalink.