Need help "translating" VBScript to VB.Net

G

Guest

I found a couple of scripts related to setting up printers on a print server
in the MS Script Repository & I need to “convert†them from VBScripts to
VB.Net. After adding the necessary ‘dim’ statements, I’m able to successful
“translate†most of the code but run into trouble with the last (and most
critical) line in both cases.
I’ve included both scripts below for your perusal.
Is there a VB.Net equivalent to either of these commands?

Thanks in advance,
Jeff

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer_
& "\root\cimv2")
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objPrinter.DriverName = "HP LaserJet 4000 Series PS"
objPrinter.PortName = "IP_169.254.110.160"
objPrinter.DeviceID = "ScriptedPrinter"
objPrinter.Location = "USA/Redmond/Building 37/Room 114"
objPrinter.Network = True
objPrinter.Shared = True
objPrinter.ShareName = "ScriptedPrinter"
objPrinter.Put_ ‘<<<<<<<<<<<<<<<<<

----------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objDriver = objWMIService.Get("Win32_PrinterDriver")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True
objDriver.Name = "Apple LaserWriter 8500"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
errResult = objDriver.AddPrinterDriver(objDriver) ‘<<<<<<<<<<<<<<<<<
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top