Const Counter=0 Const PreName="Computer-" ' CompRename.vbs ' Rename local computer using PreName + Counter ' The value of counter is increased by one each time the script is run On Error Resume Next Dim strScriptName Dim oFSO Dim oShell Dim oWMI Dim oNet Dim oScriptFile Dim oComp Dim strScriptContent Dim strOldCompName Dim strNewCompName strScriptName=Wscript.ScriptFullName Set oFSO=CreateObject("Scripting.Filesystemobject") Set oShell=CreateObject("WScript.Shell") Set oScriptFile=oFSO.OpenTextFile(strScriptName,1) oScriptFile.Skipline strScriptContent=chr(13) & chr(10) & oScriptFile.ReadAll oScriptFile.Close Set oNet = CreateObject("WScript.Network") strOldCompName=oNet.ComputerName strNewCompName=PreName & right("000" & Counter,3) Set oWMI=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") For each oComp in oWMI.InstancesOf("Win32_ComputerSystem") Return = oComp.rename(strNewCompName) If Return <> 0 Then oShell.Popup "Rename failed, check your permissions.",4 Else oShell.Popup "Computer renamed." & vbCRLF & "Old Name: " & strOldCompName & vbCRLF & _ "New Name: " & strNewCompName & vbCRLF & vbCRLF & "Will take effect after next reboot.",4 End If Next Set oScriptFile=oFSO.CreateTextFile(strScriptName,True) oScriptFile.Write "Const Counter=" & Counter+1 & strScriptContent oScriptFile.Close