Need Help with Scipts

Discussion in 'Scripting' started by Victor Asuquo, Oct 17, 2008.

  1. 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
    ' ---------------------------------------------------------------
    ' From the book "Windows Server Cookbook" by Robbie Allen
    ' Publisher: O'Reilly Media
    ' ISBN: 0-596-00633-0
    ' Book web site:
    ' ---------------------------------------------------------------

    ' ------ SCRIPT CONFIGURATION ------
    strComputer = "<ComputerName>" ' e.g. joe-xp
    strNewComputer = "<NewComputerName>" ' e.g. joe-pc
    strDomainUser = "<DomainUserUPN>" ' e.g.
    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, _
    set objWMICompSys = objWMIComp.Get("Win32_ComputerSystem.Name='" & _
    strComputer & "'")
    ' Rename Computer
    intRC = objWMICompSys.Rename(strNewComputer, _
    strDomainPasswd, _
    if intRC <> 0 then
    WScript.Echo "Rename failed with error: " & intRC
    WScript.Echo "Successfully renamed " & strComputer & " to " &
    end if

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

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

    What should I do.

    Need assistance please


    Victor Asuquo, Oct 17, 2008
    1. Advertisements

  2. Pegasus \(MVP\), Oct 17, 2008
    1. Advertisements

  3. Victor Asuquo

    Al Dunbar Guest

    Sorry, I cannot help with your RPC server unavailable issue. But the two
    things you are wanting to do - I don't think they belong in the same script.

    first, when this script runs, it might be that nobody is logged on to it.
    Second, even if someone is and the description is changed, that description
    will remain the same when other people logon. Is that your intent, or do you
    want the description to be update when each user logs on? If so, will the
    user accounts have the required privilege to do this?

    If that is what you want I think you would be better off implementing some
    sort of "session logging" facility such as described here:

    Al Dunbar, Oct 17, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.