giggity Posted October 14, 2006 Share Posted October 14, 2006 Is there a way to create TCP printer ports using runas for non admin users? I am trying to deploy printer installs on a network via login script. I can install the printer no problem if the user currently has the tcp port created but other than that I can't seem to get this to work. $Addr = "192.168.45.34" $PNumber = "9100" MakeNewPort($Addr, $PNumber) Func MakeNewPort($Address, $PortNumber) $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") $objNewPort = $objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_ $objNewPort.Name = "IP_"&$Address $objNewPort.Protocol = 1 $objNewPort.HostAddress = $Address $objNewPort.PortNumber = $PortNumber $objNewPort.SNMPEnabled = False $objNewPort.Put_ EndFunc I can't get that code to work for non admin users. Link to comment Share on other sites More sharing options...
Developers Jos Posted October 14, 2006 Developers Share Posted October 14, 2006 Is there a way to create TCP printer ports using runas for non admin users? I am trying to deploy printer installs on a network via login script. I can install the printer no problem if the user currently has the tcp port created but other than that I can't seem to get this to work. $Addr = "192.168.45.34" $PNumber = "9100" MakeNewPort($Addr, $PNumber) Func MakeNewPort($Address, $PortNumber) $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") $objNewPort = $objWMIService.Get("Win32_TCPIPPrinterPort").SpawnInstance_ $objNewPort.Name = "IP_"&$Address $objNewPort.Protocol = 1 $objNewPort.HostAddress = $Address $objNewPort.PortNumber = $PortNumber $objNewPort.SNMPEnabled = False $objNewPort.Put_ EndFunc I can't get that code to work for non admin users. Restart the script with Admin credentials .. AutoItSetOption("RunErrorsFatal", 0) AutoItSetOption("TrayIconHide", 1) Break(0) $USERNAME = "Administrator" $PASSWORD = "Secret" $RUN = 0 ; run indicator ; retrieve the cycle from commandline If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1] If $RUN = 0 Then RunAsSet($USERNAME, @ComputerName, $PASSWORD) Run('"' & @ScriptFullPath & '" " 1"') If @error Then MsgBox(4096+32,"Error", "Error starting under admin mode") Exit EndIf ; commands go here that require Administrator rights SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now