| |
defisit
Posts: 1
Score: 0
Joined: 6/12/2007
Status: offline
|
Hi, I currently have a vb script that renames the local guest account on a microsoft server system to guest_%computername%. The problem is that the script does not rename the guest account to guest_<actualcomputername> but to guest_%computername%. I would like to have a script that puts in the actual computername in stead of static value like it does now. The sript is written out here -----=====CUT HERE=====> sComputerName = "." ' use "." for local computer Set objNet = CreateObject("WScript.NetWork") Dim sOldUser Dim sNewUser sOldUser = "GUEST_%COMPUTERNAME%" sNewUser = "GUEST_" & objNet.ComputerName Set colUsers = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & sComputerName & "\root\cimv2").ExecQuery _ ("select Name from Win32_UserAccount where name = '" & sOldUser & "'") If colUsers.Count > 0 Then For Each oUser In colUsers iRC = oUser.Rename(sNewUser) If iRC = 0 Then WScript.Echo sOldUser & " renamed to " & sNewUser End if Next Else WScript.Echo "No user found" End If -----=====UNCUT HERE===< Please help
|
|