Advertisement
Guest User

createports_v1.vbs

a guest
Sep 27th, 2016
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '### For Philip from Darren Collins.
  2. '=============================
  3. strNameListFile = "C:\temp\NameList.txt"
  4. Set fso = CreateObject("Scripting.FileSystemObject")
  5. strNameList = fso.OpenTextFile(strNameListFile, 1).ReadAll
  6. arrNameList = Split(strNameList, vbCrlf)
  7.  
  8. strComputer = "."
  9.  
  10. For Each strPrinterName In arrNameList
  11.     If strPrinterName <> "" Then
  12.         Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  13.         Set objNewPort = objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_
  14.         objNewPort.Name = strPrinterName
  15.         objNewPort.Protocol = 1
  16.         objNewPort.HostAddress = strPrinterName
  17.         objNewPort.PortNumber = "9100"
  18.         objNewPort.SNMPEnabled = False
  19.         objNewPort.Put_
  20.     End If
  21. Next
  22.  
  23. MsgBox "Script Complete"
  24. WScript.Quit 0
  25. '=============================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement