Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Need Help with Scipts

Reply
Thread Tools Display Modes

Need Help with Scipts

 
 
Victor Asuquo
Guest
Posts: n/a

 
      10-17-2008
Dear All,

I have been tasked with creating a script that will rename computers on my
network. The script should be able to do the following.

Rename the computer name to the serial number of the computer

Change the computer description to the username of the logged on user.

I ran this script found on the internet for test purposes

************************************************** ***************************************
This code renames a computer in its domain and on the computer itself.
' This script works only against Windows XP and Windows Server 2003
computers.
' ---------------------------------------------------------------
' From the book "Windows Server Cookbook" by Robbie Allen
' Publisher: O'Reilly Media
' ISBN: 0-596-00633-0
' Book web site: http://rallenhome.com/books/winsckbk/code.html
' ---------------------------------------------------------------

' ------ SCRIPT CONFIGURATION ------
strComputer = "<ComputerName>" ' e.g. joe-xp
strNewComputer = "<NewComputerName>" ' e.g. joe-pc
strDomainUser = "<DomainUserUPN>" ' e.g.
strDomainPasswd = "<DomainUserPasswd>"
strLocalUser = "<ComputerAdminUser>" ' e.g. joe-xp\administrator
strLocalPasswd = "<ComputerAdminPasswd>"
' ------ END CONFIGURATION ---------
' Connect to Computer
set objWMILocator = CreateObject("WbemScripting.SWbemLocator")
objWMILocator.Security_.AuthenticationLevel = 6
set objWMIComp = objWMILocator.ConnectServer(strComputer, _
"root\cimv2", _
strLocalUser, _
strLocalPasswd)
set objWMICompSys = objWMIComp.Get("Win32_ComputerSystem.Name='" & _
strComputer & "'")
' Rename Computer
intRC = objWMICompSys.Rename(strNewComputer, _
strDomainPasswd, _
strDomainUser)
if intRC <> 0 then
WScript.Echo "Rename failed with error: " & intRC
else
WScript.Echo "Successfully renamed " & strComputer & " to " &
strNewComputer
end if

WScript.Echo "Rebooting system..."
Set colOS = objWMIComp.InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
objOS.Reboot()
next
************************************************** *************************************

Plugging in all parameters as needed but it returns the following error
SWbemLocator RPC server is unavailable.

What should I do.

Need assistance please

Thanks

VascoSputs

 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      10-17-2008
Check the answer(s) you received in scripting.vbscript and have a look at
this site to see the advantages of cross-posting vs. multi-posting:
http://www.blakjak.demon.co.uk/mul_crss.htm


"Victor Asuquo" <> wrote in message
news:FFA2128E-839A-47F9-8473-...
> Dear All,
>
> I have been tasked with creating a script that will rename computers on my
> network. The script should be able to do the following.
>
> Rename the computer name to the serial number of the computer
>
> Change the computer description to the username of the logged on user.
>
> I ran this script found on the internet for test purposes
>
> ************************************************** ***************************************
> This code renames a computer in its domain and on the computer itself.
> ' This script works only against Windows XP and Windows Server 2003
> computers.
> ' ---------------------------------------------------------------
> ' From the book "Windows Server Cookbook" by Robbie Allen
> ' Publisher: O'Reilly Media
> ' ISBN: 0-596-00633-0
> ' Book web site: http://rallenhome.com/books/winsckbk/code.html
> ' ---------------------------------------------------------------
>
> ' ------ SCRIPT CONFIGURATION ------
> strComputer = "<ComputerName>" ' e.g. joe-xp
> strNewComputer = "<NewComputerName>" ' e.g. joe-pc
> strDomainUser = "<DomainUserUPN>" ' e.g.
>
> strDomainPasswd = "<DomainUserPasswd>"
> strLocalUser = "<ComputerAdminUser>" ' e.g. joe-xp\administrator
> strLocalPasswd = "<ComputerAdminPasswd>"
> ' ------ END CONFIGURATION ---------
> ' Connect to Computer
> set objWMILocator = CreateObject("WbemScripting.SWbemLocator")
> objWMILocator.Security_.AuthenticationLevel = 6
> set objWMIComp = objWMILocator.ConnectServer(strComputer, _
> "root\cimv2", _
> strLocalUser, _
> strLocalPasswd)
> set objWMICompSys = objWMIComp.Get("Win32_ComputerSystem.Name='" & _
> strComputer & "'")
> ' Rename Computer
> intRC = objWMICompSys.Rename(strNewComputer, _
> strDomainPasswd, _
> strDomainUser)
> if intRC <> 0 then
> WScript.Echo "Rename failed with error: " & intRC
> else
> WScript.Echo "Successfully renamed " & strComputer & " to " &
> strNewComputer
> end if
>
> WScript.Echo "Rebooting system..."
> Set colOS = objWMIComp.InstancesOf("Win32_OperatingSystem")
> for each objOS in colOS
> objOS.Reboot()
> next
> ************************************************** *************************************
>
> Plugging in all parameters as needed but it returns the following error
> SWbemLocator RPC server is unavailable.
>
> What should I do.
>
> Need assistance please
>
> Thanks
>
> VascoSputs



 
Reply With Quote
 
Al Dunbar
Guest
Posts: n/a

 
      10-17-2008
Sorry, I cannot help with your RPC server unavailable issue. But the two
things you are wanting to do - I don't think they belong in the same script.

first, when this script runs, it might be that nobody is logged on to it.
Second, even if someone is and the description is changed, that description
will remain the same when other people logon. Is that your intent, or do you
want the description to be update when each user logs on? If so, will the
user accounts have the required privilege to do this?

If that is what you want I think you would be better off implementing some
sort of "session logging" facility such as described here:

http://www.rlmueller.net/Logon5.htm


/Al

"Victor Asuquo" <> wrote in message
news:FFA2128E-839A-47F9-8473-...
> Dear All,
>
> I have been tasked with creating a script that will rename computers on my
> network. The script should be able to do the following.
>
> Rename the computer name to the serial number of the computer
>
> Change the computer description to the username of the logged on user.
>
> I ran this script found on the internet for test purposes
>
> ************************************************** ***************************************
> This code renames a computer in its domain and on the computer itself.
> ' This script works only against Windows XP and Windows Server 2003
> computers.
> ' ---------------------------------------------------------------
> ' From the book "Windows Server Cookbook" by Robbie Allen
> ' Publisher: O'Reilly Media
> ' ISBN: 0-596-00633-0
> ' Book web site: http://rallenhome.com/books/winsckbk/code.html
> ' ---------------------------------------------------------------
>
> ' ------ SCRIPT CONFIGURATION ------
> strComputer = "<ComputerName>" ' e.g. joe-xp
> strNewComputer = "<NewComputerName>" ' e.g. joe-pc
> strDomainUser = "<DomainUserUPN>" ' e.g.
>
> strDomainPasswd = "<DomainUserPasswd>"
> strLocalUser = "<ComputerAdminUser>" ' e.g. joe-xp\administrator
> strLocalPasswd = "<ComputerAdminPasswd>"
> ' ------ END CONFIGURATION ---------
> ' Connect to Computer
> set objWMILocator = CreateObject("WbemScripting.SWbemLocator")
> objWMILocator.Security_.AuthenticationLevel = 6
> set objWMIComp = objWMILocator.ConnectServer(strComputer, _
> "root\cimv2", _
> strLocalUser, _
> strLocalPasswd)
> set objWMICompSys = objWMIComp.Get("Win32_ComputerSystem.Name='" & _
> strComputer & "'")
> ' Rename Computer
> intRC = objWMICompSys.Rename(strNewComputer, _
> strDomainPasswd, _
> strDomainUser)
> if intRC <> 0 then
> WScript.Echo "Rename failed with error: " & intRC
> else
> WScript.Echo "Successfully renamed " & strComputer & " to " &
> strNewComputer
> end if
>
> WScript.Echo "Rebooting system..."
> Set colOS = objWMIComp.InstancesOf("Win32_OperatingSystem")
> for each objOS in colOS
> objOS.Reboot()
> next
> ************************************************** *************************************
>
> Plugging in all parameters as needed but it returns the following error
> SWbemLocator RPC server is unavailable.
>
> What should I do.
>
> Need assistance please
>
> Thanks
>
> VascoSputs



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE scipts chronis Internet Explorer 0 12-16-2007 11:12 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59