Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Need help with script

Reply
 
Old 10-17-2008   #1 (permalink)
VascoSputs


 
 

Need help with script

Dear All,

I have been tasked with creating a script that will rename computers on my
network. The script should be able to do the following.

Rename the computer name to the serial number of the computer

Change the computer description to the username of the logged on user.

I ran this script found on the internet for test purposes

*****************************************************************************************
This code renames a computer in its domain and on the computer itself.
' This script works only against Windows XP and Windows Server 2003
computers.
' ---------------------------------------------------------------
' From the book "Windows Server Cookbook" by Robbie Allen
' Publisher: O'Reilly Media
' ISBN: 0-596-00633-0
' Book web site: http://rallenhome.com/books/winsckbk/code.html
' ---------------------------------------------------------------

' ------ SCRIPT CONFIGURATION ------
strComputer = "<ComputerName>" ' e.g. joe-xp
strNewComputer = "<NewComputerName>" ' e.g. joe-pc
strDomainUser = "<DomainUserUPN>" ' e.g. administrator@xxxxxx
strDomainPasswd = "<DomainUserPasswd>"
strLocalUser = "<ComputerAdminUser>" ' e.g. joe-xp\administrator
strLocalPasswd = "<ComputerAdminPasswd>"
' ------ END CONFIGURATION ---------
' Connect to Computer
set objWMILocator = CreateObject("WbemScripting.SWbemLocator")
objWMILocator.Security_.AuthenticationLevel = 6
set objWMIComp = objWMILocator.ConnectServer(strComputer, _
"root\cimv2", _
strLocalUser, _
strLocalPasswd)
set objWMICompSys = objWMIComp.Get("Win32_ComputerSystem.Name='" & _
strComputer & "'")
' Rename Computer
intRC = objWMICompSys.Rename(strNewComputer, _
strDomainPasswd, _
strDomainUser)
if intRC <> 0 then
WScript.Echo "Rename failed with error: " & intRC
else
WScript.Echo "Successfully renamed " & strComputer & " to " &
strNewComputer
end if

WScript.Echo "Rebooting system..."
Set colOS = objWMIComp.InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
objOS.Reboot()
next
***************************************************************************************

Plugging in all parameters as needed but it returns the following error
SWbemLocator RPC server is unavailable.

What should I do.

Need assistance please

Thanks

VascoSputs

--
EdemObong

My System SpecsSystem Spec
Old 10-17-2008   #2 (permalink)
Al Dunbar


 
 

Re: Need help with script

Please don't multi-post.

/Al

"VascoSputs" <VascoSputs@xxxxxx> wrote in message
news:2807B13D-C343-4D30-B782-0B1F670DB31C@xxxxxx
Quote:

> Dear All,
>
> I have been tasked with creating a script that will rename computers on my
> network. The script should be able to do the following.
>
> Rename the computer name to the serial number of the computer
>
> Change the computer description to the username of the logged on user.
>
> I ran this script found on the internet for test purposes
>
> *****************************************************************************************
> This code renames a computer in its domain and on the computer itself.
> ' This script works only against Windows XP and Windows Server 2003
> computers.
> ' ---------------------------------------------------------------
> ' From the book "Windows Server Cookbook" by Robbie Allen
> ' Publisher: O'Reilly Media
> ' ISBN: 0-596-00633-0
> ' Book web site: http://rallenhome.com/books/winsckbk/code.html
> ' ---------------------------------------------------------------
>
> ' ------ SCRIPT CONFIGURATION ------
> strComputer = "<ComputerName>" ' e.g. joe-xp
> strNewComputer = "<NewComputerName>" ' e.g. joe-pc
> strDomainUser = "<DomainUserUPN>" ' e.g.
> administrator@xxxxxx
> strDomainPasswd = "<DomainUserPasswd>"
> strLocalUser = "<ComputerAdminUser>" ' e.g. joe-xp\administrator
> strLocalPasswd = "<ComputerAdminPasswd>"
> ' ------ END CONFIGURATION ---------
> ' Connect to Computer
> set objWMILocator = CreateObject("WbemScripting.SWbemLocator")
> objWMILocator.Security_.AuthenticationLevel = 6
> set objWMIComp = objWMILocator.ConnectServer(strComputer, _
> "root\cimv2", _
> strLocalUser, _
> strLocalPasswd)
> set objWMICompSys = objWMIComp.Get("Win32_ComputerSystem.Name='" & _
> strComputer & "'")
> ' Rename Computer
> intRC = objWMICompSys.Rename(strNewComputer, _
> strDomainPasswd, _
> strDomainUser)
> if intRC <> 0 then
> WScript.Echo "Rename failed with error: " & intRC
> else
> WScript.Echo "Successfully renamed " & strComputer & " to " &
> strNewComputer
> end if
>
> WScript.Echo "Rebooting system..."
> Set colOS = objWMIComp.InstancesOf("Win32_OperatingSystem")
> for each objOS in colOS
> objOS.Reboot()
> next
> ***************************************************************************************
>
> Plugging in all parameters as needed but it returns the following error
> SWbemLocator RPC server is unavailable.
>
> What should I do.
>
> Need assistance please
>
> Thanks
>
> VascoSputs
>
> --
> EdemObong

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Logon Script Causing Laptops To Hang - Problems in script? VB Script
problem passing args to script 'There is no script engine for file extenstion' VB Script
Include another script, keep variables in included script? PowerShell
Script file has 'OS Handle' error when run from script PowerShell
Can you drag-n-drop a file on top of a PS script to run the script? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46