Windows 10: VBS Script Renaming a pc script fails

  1.    22 Feb 2018 #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 ComputerSystem Spec

  2.    22 Feb 2018 #2

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


 

Related Threads
Script error in General Support
I started getting this script error last evening. I think it seems to happen when I open Chrome, but I may be wrong about that. I tried bringing up Run, typed in %temp%, deleted all temp files and the restarted but as soon as I opened Chrome...
I am using Windows 10 Home on a HP i3 laptop. Just recently I have started receiving an error pop-up which says "Windows Script Host - There is no script engine for file extension ".js"". There doesn't seem to be a pattern to when the error...
Unresponsive script in General Support
Unresponsive script with Windows 10. A lot of websites cause this issue, the computer and/or browser go off into busy never never land, and even when I get control back it is slow or goes back to never never land !! I looked up reasons and fixes...
Sub-script and Super-script in General Support
Is it possible to use sub-script and super-script when typing emails with Windows 10? I was able to do this when using Windows 7 and typing documents but not for emails. I was expecting that with the major up-grade to from 7 to 10 it would now be...
w10, Script Error in General Support
Why suddenly " Script Error " appears continuously when I try to close an IE page? asking to choose "use script Yes or NO". & either clicked gives an blank page & have difficulty closing it. I tried Tools>Advanced & "disable script errors" is...
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 23:22.
Find Us