1
votes

So I need to write a script to map 60 printers for about 20 users on RDS. Problem is the script is only mapping printers to line 14, but it's running until the last line. I know it's runnign to the last line because the last line is: a=msgbox("All printers are mapped. Default printer is set. Click OK to close. Scripting by Nick, donations welcome.")

All humor aside, I was trying to find a way to break my script into multiple scripts with one script calling the rest. If someone has a better idea I'm all eyes! But here's a sample of the code I'm using:

Dim Net Set objNetwork = Wscript.CreateObject("Wscript.Network") objNetwork.AddWindowsPrinterConnection "\printserver\printer name1", "domain\admin", "password" objNetwork.AddWindowsPrinterConnection "\printserver\printer name1", "domain\admin", "password" objNetwork.AddWindowsPrinterConnection "\printserver\printer name1", "domain\admin", "password" objNetwork.AddWindowsPrinterConnection "\printserver\printer name1", "domain\admin", "password" objNetwork.AddWindowsPrinterConnection "\printserver\printer name1", "domain\admin", "password"

1
Did you just format this really awful, or do you really have all these as one line of text? I can't see this working at all. - Nathan Rice
Actually it's working now but the problem that I'm having is that it won't run unless the user is a local admin on that computer. I've tried executing from CMD run as admin, but I'm not having much luck with that. It will run one line then quit. It does map the printer for the line that it just ran. Is there a way to establish credentials at the start of the script? - Nxahoward

1 Answers

1
votes
runas /user: <username> cscript.exe yourscript.vbs

or

psexec -u <username> -p <password> cscript.exe yourscript.vbs

http://technet.microsoft.com/en-us/sysinternals/bb897553