Jump to content

Having trouble with PRINTUI arguements exporting Printer Drivers.


Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"')

 

Link to comment
Share on other sites

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!

 

 

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 & '"')

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...