Created
March 27, 2011 18:04
-
-
Save mattrude/889424 to your computer and use it in GitHub Desktop.
Changes My Computer to actual Computername
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'============================================================================== | |
'LANG : VBScript | |
'NAME : computername.vbs | |
'DESCRIPTION: Changes My Computer to actual Computername | |
'============================================================================== | |
Option Explicit | |
Const HKEY_CLASSES_ROOT = &H80000000 | |
Const HKEY_CURRENT_USER = &H80000001 | |
Const HKEY_LOCAL_MACHINE = &H80000002 | |
Const HKEY_USERS = &H80000003 | |
Const HKEY_PERFORMANCE_DATA = &H80000004 | |
Const HKEY_CURRENT_CONFIG = &H80000005 | |
Const HKEY_DYN_DATA = &H80000006 | |
Const REG_NONE = 0 | |
Const REG_SZ = 1 | |
Const REG_EXPAND_SZ = 2 | |
Const REG_BINARY = 3 | |
Const REG_DWORD = 4 | |
Const REG_DWORD_LITTLE_ENDIAN = 4 | |
Const REG_DWORD_BIG_ENDIAN = 5 | |
Const REG_LINK = 6 | |
Const REG_MULTI_SZ = 7 | |
Const REG_RESOURCE_LIST = 8 | |
Dim strComputer | |
Dim objReg | |
Dim strKeyPath | |
Dim strValueName | |
Dim strValue | |
'============================================================================== | |
'============================================================================== | |
'Main Body | |
On error resume next | |
strComputer = "." | |
'wscript.echo "Binding to Registry Provider" | |
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") | |
strKeyPath = "CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}" | |
strValueName = "LocalizedString" | |
strValue = "%COMPUTERNAME%" | |
'wscript.echo "Setting Registry Key" | |
objReg.SetExpandedStringValue HKEY_CLASSES_ROOT,strKeyPath,strValueName,strValue | |
if Err.Number <> 0 then | |
wscript.echo ("Error # " & CStr(Err.Number) & " " & Err.Description) | |
End if | |
wscript.quit (Err.number) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment