How can I automatically rename the My Computer desktop icon so that it includes the host name?

John Savill

August 31, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. The following code renames the My Computer icon on the desktop to "My Computer ". You can run the code as a domain-level logon script or call it from another script.

option explicitdim objNetwork, objShell, strComputer, objFolder, objFolderItemConst MY_COMPUTER = &H11&Set objNetwork = CreateObject("Wscript.Network")Set objShell = CreateObject("Shell.Application")strComputer = objNetwork.ComputerNameSet objFolder = objShell.Namespace(MY_COMPUTER)Set objFolderItem = objFolder.SelfobjFolderItem.Name = "My Computer " & strComputer

You can change the last line to be any text that you want to use for the My Computer icon. It doesn't need to begin with My Computer.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like