Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
error
Logged in as: Guest
arrSession:exec spGetSession 2,2,37958
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
WSH & Client Side VBScript
>> error
Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page:
[1]
Login
Message
<< Older Topic
Newer Topic >>
error -
9/20/2006 6:28:15 PM
beer78
Posts: 1
Score: 0
Joined: 9/20/2006
Status:
offline
I'm new in VB script, and I build this in notepad.
But what do i do wrong.
'---------------------------------------------------------- ' Initialiseren Objecten '---------------------------------------------------------- Dim Shell, Network, Fso, computernaam, serienummer, strcomputer, objWMIService, colItems, objItem, colOperatingSystems, objOperatingSystem Set Shell=WScript.CreateObject ("Wscript.Shell") Set Network=WScript.CreateObject ("Wscript.Network") Set Fso=WScript.Createobject ("Scripting.FileSystemObject") '---------------------------------------------------------- ' Computernaam variabele vullen '---------------------------------------------------------- On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_SystemEnclosure",,48) For Each objItem in colItems serienummer = (objItem.SMBiosAssetTag) computernaam = UCASE("Casema - " & serienummer) Next '---------------------------------------------------------- ' Computernaam aanpassen '---------------------------------------------------------- Wscript.Echo "computernaam aanpassen" Wscript.Echo computernaam wscript.sleep 10000 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(computernaam) 'If Err <> "0" Then WScript.Echo ("Er is een fout opgetreden") Next '---------------------------------------------------------- ' Domein.vbs klaarzetten '---------------------------------------------------------- Wscript.Echo "domein.vbs in runonce plaatsen" Shell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\domein","cscript c:\windows\system32\domein.vbs","REG_SZ" '---------------------------------------------------------- ' Herstarten computer '---------------------------------------------------------- Wscript.Echo "Herstarten van de computer." Set objWMIService=GetObject ("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\.\root\cimv2") Set colOperatingSystems=objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems objOperatingSystem.Reboot() Next Wscript.Quit
I think It goes wrong in the "Computernaam aanpassen" section. because the error "Er is een fout opgetreden" comes in a messagebox.
I hope someone can help me with this. and i hope someone can give me a freeware tool where i can test this code
Post #: 1
RE: error -
9/21/2006 12:18:24 AM
Snipah
Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status:
offline
Beer78,
You can use the Rename method to rename a computer. If you are a member of the local administrator group. However, you cannot use the method remotely for domain computers.
Please refer to this page for more info:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/rename_method_in_class_win32_computersystem.asp
S.
_____________________________
For more information, please see the "
Read me First
" topic.
http://www.visualbasicscript.com
(in reply to
beer78
)
Post #: 2
If you found our site useful please link to us
<a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>
.
All Forums
>>
[Scripting]
>>
WSH & Client Side VBScript
>> error
Page:
[1]
Jump to:
Select a Forum
All Forums
----------------------
[Welcome]
- - Forum Rules
- - Test Posting Messages
- - New Member Area/Introduction
[Scripting]
- - WSH & Client Side VBScript
- - WSH & Client Side VBScript Tutorial
- - Post a VBScript
- - Windows PowerShell
- - ASP
- - ASP.NET
- - Windows Script Components
[General Forum]
- - Other Programming/Scripting Languages
- - Suggestions & Feedback
- - Off-Topic Lounge
New Messages
No New Messages
Hot Topic w/ New Messages
Hot Topic w/o New Messages
Locked w/ New Messages
Locked w/o New Messages
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
Forum Software ©
ASPPlayground.NET
Advanced Edition
2.5.5 ANSI