K1000, online kscript, run as local system, Microsoft Windows - I have the following:

Launch "SYS\ runas /user:administrator cmd.exe" with params "/c wmic ComputerSystem where Caption='CCILTIT99' call Rename Name=CCILTIT12"

With or without the runas the script fails with error code 5 'access is denied.

Any thoughts?


3 Comments   [ - ] Hide Comments


  • Any chance the computer is on a domain? If it is then the error 5 might indicate that the local user doesn't have permission to change the domain account.
  • yes on a domain but I thought the runas administrator would take care of that.
  • Run as administrator just takes care of rights on the local PC. You have to be logged in as a user that has modify rights to the machine account at the domain level.
Please log in to comment

Answer this question or Comment on this question for clarity



I had to unjoin them, rename, and rejoin them to get wmic to work for machines in the domain.

You may also be able to run the script as a domain user that has local admin rights as well as rights to rename machines in the domain.

to unjoin a machine:

Wmic computersystem where name="%computername%" call unjoindomainorworkgroup

Answered 03/06/2014 by: SMal.tmcc
Red Belt

  • I use this vbs to join the machines:

    Const JOIN_DOMAIN = 1
    Const ACCT_CREATE = 2
    Const ACCT_DELETE = 4
    Const WIN9X_UPGRADE = 16
    Const JOIN_UNSECURE = 64
    Const DEFERRED_SPN_SET = 256
    Const INSTALL_INVOCATION = 262144

    If WScript.Arguments.Count < 3 or WScript.Arguments.Count > 4 Then
    strDomain = WScript.Arguments.Item(0)
    strUser = WScript.Arguments.Item(1)
    strPassword = WScript.Arguments.Item(2)

    'set DNS IP address
    If WScript.Arguments.Count = 4 Then
    strDNSIP = WScript.Arguments.Item(3)
    Set objShell = CreateObject("WScript.shell")
    objShell.Run "netsh int ip set dns ""local area connection"" static "& _
    strDNSIP &" primary",0,0
    End If

    End If

    Set objNetwork = CreateObject("WScript.Network")
    strComputer = objNetwork.ComputerName

    Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
    strComputer & _
    "\root\cimv2:Win32_ComputerSystem.Name='" _
    & strComputer & "'")
    ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, _
    strDomain & "\" & strUser, _
    NULL, _

    cscript.exe -b join_domain.vbs domain.tmcc.edu domainuser password DCip
Please log in to comment

I too use a vbs but much smaller and not via KACE:

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = inputbox ("Please Enter Computer Name","Enter Computer Name","brooklyn-7")

Set objRegistry = GetObject _
("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "System\CurrentControlSet\Services\lanmanserver\parameters"
strValueName = "srvcomment"
strDescription = inputbox ("Please Enter New Description","Enter Description",".")

objRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDescription

strKeyPath = "System\CurrentControlSet\Services\lanmanserver\parameters\srvcomment"

' Wscript.Echo strDescription

Msgbox("Computer Description Sucessfully Changed to " & strDescription )
Answered 03/07/2014 by: worzie
Third Degree Green Belt

Please log in to comment