Vbscript adding network printers with username variable


Recommended Posts

Good Morning All 

 

This is my first post, so please be gentle :) 

 

I am looking to network 8 printers but i want them to be mapped to a username e.g 

'customer services script
Dim obj
	Set obj = CreateObject("Wscript.Network")
	
WScript.Echo obj.UserName = "gbcg01,gbxx01,gbxx02" Then
	objWshNetwork.AddWindowsPrinterConnection "\\Myserver\Printer
	
	
'run my next script for the next department
objShell.Run "Warehouse_script.vbs"

We cannot use GPO as we are a subsidiary and the main IT are useless

 

any chance of a hand? 

Thanks 

 

Link to comment
Share on other sites

 Something like this:

Set objNetwork = CreateObject("WScript.Network")

If objNetwork.UserName = "TestUsername1" Then
objNetwork.AddWindowsPrinterConnection "\\server\printer x"

objNetwork.SetDefaultPrinter "\\server\Printer X"

end if

If objNetwork.UserName = "TestUsername2" Then

     objNetwork.AddWindowsPrinterConnection "\\server\printer y"
    objNetwork.SetDefaultPrinter "\\server\Printer Y"

end if

 

Link to comment
Share on other sites

This topic is now closed to further replies.