VB Newbie: New ConnectionOptions() causes "Expected end of statement"
From: Peter Valdemar Mørch (4nr8e4s02_at_sneakemail.com)
Date: 02/28/04
- Previous message: Ali AYEN: "Re: New ServerBinding entry"
- Next in thread: Viatcheslav V. Vassiliev: "Re: VB Newbie: New ConnectionOptions() causes "Expected end of statement""
- Reply: Viatcheslav V. Vassiliev: "Re: VB Newbie: New ConnectionOptions() causes "Expected end of statement""
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 28 Feb 2004 09:45:34 +0100
I have my tiny WMI script working when logged in on localhost as a
user with Administrator credentials on the remote host.
Now I'm trying to modify it to access a remote host as another user
than the one currently logged in on localhost.
I therefore put the follwing snippet in a "hello.vbs" file with
notepad:
Imports System
Imports System.Management
Dim options As New ConnectionOptions()
options.Username = "User"
options.Password = "password"
Dim scope As New ManagementScope("\\host\root\cimv2",options)
scope.Connect()
<snipped: yada yada yada>
When I dbl-click hello.vbs I get a "Expected end of statement"
"Windows Script Host" error where the source is "Microsoft VBScript
compliation error" for line 3, the New ConnectionOptions() line. (In
fact, trying to create a ManagementScope() instance instead triggers
the same error too)
I think the script is basically sound, as I've seen variations on that
same theme a zillion places on the net. But need I do anthing special?
Do I need to install some special microsoft suite or do something to run
it other than putting the code in a .vbs file and run it with wscript?
Dbl-clicking it or running it under cmd yields the same behaviour. I
also tried putting the script into my Excel visual basic editor and
into the "Windows .NET server resource kit - Scriptomatic"
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/tools/wmimatic.asp
and got the same results.
I'm running Windows XP Professional with .NET 1.1 installed (I'm a
little unsure whether .NET is required but I already had it
installed...)
Any help wildly appreciated!!
-- Peter Valdemar Mørch http://www.morch.com
- Previous message: Ali AYEN: "Re: New ServerBinding entry"
- Next in thread: Viatcheslav V. Vassiliev: "Re: VB Newbie: New ConnectionOptions() causes "Expected end of statement""
- Reply: Viatcheslav V. Vassiliev: "Re: VB Newbie: New ConnectionOptions() causes "Expected end of statement""
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|