Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

dsquery - works from command line but autoit returns blank string

$
0
0

Good Morning Guys

 

Im revisiting an old little project

 

The code segment below uses dsquery to extract the full path to a shared printer from AD and then uses a powershell command to add it.

 

Running the individual commands from cmd works 

 

When i run the script below the dsquery line returns nothing.

 

i would be greatful if a set of fresh/or more experienced eyes could point me in the direction of what im missing :) 

 

Thanks

Grant

#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <IE.au3> #include <AD.au3> #include <Constants.au3> #include <array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $printers = InputBox("","Enter Printer name") $command = 'dsquery * domainroot -filter "(&(objectClass=PrintQueue)(printername="'&$printers&'"))" -attr uncname -q' MsgBox(0,"",$command) $dsqOutput = RunWait(@ComSpec & '/k' & $command, @SystemDir, $STDOUT_CHILD) MsgBox(0,"",$dsqOutput) Sleep (2000) $CN = StdoutRead($dsqOutput) MsgBox(0,"",$cn) $CN = StringTrimLeft($cn,1) $CN = Stringtrimright($CN,4) $command = "([wmiclass]'Win32_Printer').AddPrinterConnection('"&$CN&"')" Run(@ComSpec & ' /k Powershell -command ' & $command)

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>