slybry70 0 Posted June 19, 2020 Afternoon all, I am working on a PRINTUI script that does various things but at the moment I am tackling exporting drivers from a network server to another domain location. this is the case I have so far. Case $Exportdriverb GetPrintServer() GetPrinterName() $Filepath = "\\" & $PrintServer & "\" & $PrinterNameString $DriverFilePath = "\\EPEPS007\printer_configs$\DATs\config.dat" RunAsWait ($Username, "SL6.MYCompany-INT.ORG", $Password, $RUN_LOGON_NETWORK, 'RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n ' & $FilePath /a "\\EPEPS007\printer_configs$\DATs\config.dat") This is only the case section but it stands alone other then variables coming into it. I use the RunAsWait command in other area's of the script and it works. I also tried this and it gave me an unknown function name error. RunAsWait ($Username, "SL6.MYCompany-INT.ORG $Password, $RUN_LOGON_NETWORK, 'RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n ' "\\PRINTER\ITD0042" /a "\\EPPEPS007\printer_configs$\DATs\config.dat") This section works to bring up printer properties with no issues so most of the script is correct. It seems to not like the /a but not sure. RunAsWait ($Username, "SL6.MYCompany-INT.ORG", $Password, $RUN_LOGON_NETWORK, 'RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /p /n ' & $FilePath & '', "") According to microsoft this is the format it should take: RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n "printer" /a "file.dat" I am sure I am just putting the arguements in wrong but have tried everything I can think of. It doesn't like the /a. but according to microsoft and all other websites out there it should be in there. Any help is appreciated. Thank you. Share this post Link to post Share on other sites
slybry70 0 Posted June 24, 2020 So update.. I have verified that this command is working in command prompt. RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n "\\PRINTSERVER\ITD0042" /a "\\pepeps007\printer_configs$\DATs\config.dat" This is my current line and its almost running! There are no errors and grammar seems correct. Only thing is that Its still not recognizing the /a RunAsWait ($Username, "SLSS12.MYCOMP-INT.ORG", $Password, $RUN_LOGON_NETWORK, 'RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n', "\\PRINTSERVER\ITD0042", '/a', "\\pepeps007\printer_configs$\DATs\config.dat") temp.au3 Can anyone think of any other grammar rules that the /a needs to be surrounded by? Its not erroring out currently but its acting like it does not see the /a. Share this post Link to post Share on other sites
Nine 930 Posted June 24, 2020 Try this : RunAsWait ($Username, "SLSS12.MYCOMP-INT.ORG", $Password, $RUN_LOGON_NETWORK, _ 'RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n "\\PRINTSERVER\ITD0042" /a "\\pepeps007\printer_configs$\DATs\config.dat"') Not much of a signature, but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Tool to search content in au3 files Date Range Picker Sudoku Game 2020 Overlapped Named Pipe IPC x64 Bitwise Operations Fast and simple WCD IPC GIF Animation (cached) Share this post Link to post Share on other sites
slybry70 0 Posted June 24, 2020 You rock! That works! TY so much! Share this post Link to post Share on other sites
slybry70 0 Posted June 27, 2020 Sorry one more question. I am replacing the text in the line with variables. How would I format it if I got rid of the static line with variables like this? Its not working currently with added variables. I am sure its grammar once again. GetPrintServer() GetPrinterName() GetFileName() $Filepath = "\\" & $PrintServer & "\" & $PrinterNameString RunAsWait ($Username, "SLSS12.MYCOMP-INT.ORG", $Password, $RUN_LOGON_NETWORK, 'RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n $Filepath /a "\\pepeps007\printer_configs$\DATs\" & $FileNameString') The filepath is coming out correctly with MSGBOX so it should be going to the correct print server and printer like I had put it in as text but its not connecting with the printer when adding it as a variable. Output of Filepath: \\PRINTSERVER\ITD0042 which is correct. How would the grammar change when taking out the text and replacing with variables? Thank you! Share this post Link to post Share on other sites
ahmet 8 Posted June 27, 2020 Try following to see the output command ConsoleWrite('RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n $Filepath /a "\\pepeps007\printer_configs$\DATs\" & $FileNameString' & @CRLF) You can try this 'RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n ' & $Filepath & ' /a "\\pepeps007\printer_configs$\DATs\" ' & $FileNameString Notice the use of "&" to concatenate (combine) strings. More info can be found at Language Reference - Datatypes. Remember to print that to console to see if you get what you are expecting. Share this post Link to post Share on other sites
slybry70 0 Posted June 28, 2020 TY. I was able to get it working like this. RunAsWait ($Username, "SLSS12.MYCOMP-INT.ORG", $Password, $RUN_LOGON_NETWORK, 'RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n' & $Filepath & ' /a ' & $FileNamePath & '') TY for the nudge in the right direction. Share this post Link to post Share on other sites
ahmet 8 Posted June 28, 2020 You are welcome. By the way it should work without last & '' It looks like as if you are adding a string of zero length. Share this post Link to post Share on other sites
Nine 930 Posted June 28, 2020 It will work I believe only if there is no blank inside the $Filepath and $FileNamePath. To ensure robustness, embed those 2 variables with double-quotes : RunAsWait ($Username, "SLSS12.MYCOMP-INT.ORG", $Password, $RUN_LOGON_NETWORK, 'RUNDLL32.EXE PRINTUI.DLL,PrintUIEntry /Ss /n "' & $Filepath & '" /a "' & $FileNamePath & '"') Not much of a signature, but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Tool to search content in au3 files Date Range Picker Sudoku Game 2020 Overlapped Named Pipe IPC x64 Bitwise Operations Fast and simple WCD IPC GIF Animation (cached) Share this post Link to post Share on other sites