VBS Script Renaming a pc script fails


  1. Posts : 11
    Windows 10
       #1

    VBS Script Renaming a pc script fails


    can anyone tell me why this script fails with rc=5.. I am not very well versedin resolving scripts....
    MUCH APPRECIATED IN ADVANCE!


    Const JOIN_DOMAIN = 1
    Const ACCT_CREATE = 2
    Const ACCT_DELETE = 4
    Const WIN9X_UPGRADE = 16
    Const DOMAIN_JOIN_IF_JOINED = 32
    Const JOIN_UNSECURE = 64
    Const MACHINE_PASSWORD_PASSED = 128
    Const DEFERRED_SPN_SET = 256
    Const INSTALL_INVOCATION = 262144
    Name = InputBox("Enter asset tag number:", "Identify Computer")
    username = "addcomputer"
    password = "XXXXXX"
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!" & strComputer & "\root\cimv2")
    Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
    For Each objComputer in colComputers
    err = objComputer.Rename(Name, Password, Username)
    If Err.Number = 0 Then
    WScript.Echo "Successfully renamed computer to " & name & "!"
    WScript.Echo "*** NOTE : You !MUST! restart pc for name change to take effect!"
    WScript.Echo "*** NOTE : You !MUST! restart pc for name change to take effect!"
    WScript.Echo "*** NOTE : You !MUST! restart pc for name change to take effect!"
    Call endit
    Else
    WScript.Echo "An error occurred renaming the computer!"
    WScript.Echo "Error Number: " & Err.Number
    WScript.Echo "Error" & Err.Description
    End If
    Next
    Sub endit
    End Sub
      My Computer


  2. Posts : 11
    Windows 10
    Thread Starter
       #2

    Byt the way .. this is being run on Windows 10 64 bit machines.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 02:13.
Find Us




Windows 10 Forums