YZlat
asked on
Computer rename script does not work on Windows 7
The VBScript below works fine on Windows XP but doe snot on Windows 7. It runs without an error but does not rename. Username login provided is an elevated account
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
ErrCode = objComputer.Rename(new_name, strPassword, strUser)
If ErrCode <> 0 Then
HandleError(ErrCode)
End If
Next
Try via Powershell: http://powershell.com/cs/media/p/922.aspx
ASKER
I need to use VBScript for that. Besides, that powershell does exactly the same thing
It looks like you are trapping for errors, could I see the rest of the script, including the error handler?
Also, have you tried removing the following line to see if any errors are reported.
Also, have you tried removing the following line to see if any errors are reported.
On Error Resume Next
~bp
Hi YZlat,
I just tested your code on my Windows 7 64bit pc and it ran fine. I dont think that there is a problem with your script, rather I think the change is being stopped by User Account Control.
I would suggest you turning User Account Control off via the "Change User Account Control settings" under the "User Accounts" option in the control panel by moving the slider to "Never notify" and then re-test your script on the pc.
I just tested your code on my Windows 7 64bit pc and it ran fine. I dont think that there is a problem with your script, rather I think the change is being stopped by User Account Control.
I would suggest you turning User Account Control off via the "Change User Account Control settings" under the "User Accounts" option in the control panel by moving the slider to "Never notify" and then re-test your script on the pc.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was not exactly it, but it was an issue not related to my script. Thank you for your help