I am attempting to write my first batch program to automate installing printers. I run into a problem when I try and execute
IF %input%==N (rundll32 printui.dll PrintUIEntry /in /n\printerserver%printer%) ELSE (rundll32 printui.dll PrintUIEntry /in /y /n\printserver%printer%)
It throws an error saying “rundll32 not expected”
I’m wondering if this is an error with the wrong IF syntax since I’m new to batch and, rundll32 printui.dll PrintUIEntry /in /n\printserverprinter
works flawlessly in CMD.
<code>:: List the printers available to install
ECHO Please type from the list the printer you would like to install (Case Sensitive): List, of, printers
:: Gives the use the choice of which printer to install and stores it in a variable
SET /p %printer%=CHOICE /c List, of, printers /cs /n /m "Please type the printer of your choice:"
:: Asks if the printer being installed should be the default printer
ECHO Would you like the printer being installed to be your default printer?
:: Asks if the printer being installed should be the default printer and stores the answer as a variable
IF %input%==N (rundll32 printui.dll PrintUIEntry /in /n\printserver%printer%) ELSE (rundll32 printui.dll PrintUIEntry /in /y /n\printserver%printer%)
:: Want I want to happen V
:: Ask user if they want to set printer as default
:: Store input as a variable
:: Ask what printer they want installed
:: Store input as a variable
:: Run rundll32 printui.dll PrintUIEntry /in /n\client1printer1 if they said no to default printer
:: Run rundll32 printui.dll PrintUIEntry /in /y /n\client1printer1 if they said yes to default printer
<code>:: List the printers available to install
ECHO Please type from the list the printer you would like to install (Case Sensitive): List, of, printers
:: Gives the use the choice of which printer to install and stores it in a variable
SET /p %printer%=CHOICE /c List, of, printers /cs /n /m "Please type the printer of your choice:"
:: Asks if the printer being installed should be the default printer
ECHO Would you like the printer being installed to be your default printer?
ECHO Y,N
:: Asks if the printer being installed should be the default printer and stores the answer as a variable
SET /p %input%=CHOICE /c
:: Installs the printer
IF %input%==N (rundll32 printui.dll PrintUIEntry /in /n\printserver%printer%) ELSE (rundll32 printui.dll PrintUIEntry /in /y /n\printserver%printer%)
Pause
:: Want I want to happen V
:: Ask user if they want to set printer as default
:: Store input as a variable
:: Ask what printer they want installed
:: Store input as a variable
:: Run rundll32 printui.dll PrintUIEntry /in /n\client1printer1 if they said no to default printer
:: Run rundll32 printui.dll PrintUIEntry /in /y /n\client1printer1 if they said yes to default printer
</code>
:: List the printers available to install
ECHO Please type from the list the printer you would like to install (Case Sensitive): List, of, printers
:: Gives the use the choice of which printer to install and stores it in a variable
SET /p %printer%=CHOICE /c List, of, printers /cs /n /m "Please type the printer of your choice:"
:: Asks if the printer being installed should be the default printer
ECHO Would you like the printer being installed to be your default printer?
ECHO Y,N
:: Asks if the printer being installed should be the default printer and stores the answer as a variable
SET /p %input%=CHOICE /c
:: Installs the printer
IF %input%==N (rundll32 printui.dll PrintUIEntry /in /n\printserver%printer%) ELSE (rundll32 printui.dll PrintUIEntry /in /y /n\printserver%printer%)
Pause
:: Want I want to happen V
:: Ask user if they want to set printer as default
:: Store input as a variable
:: Ask what printer they want installed
:: Store input as a variable
:: Run rundll32 printui.dll PrintUIEntry /in /n\client1printer1 if they said no to default printer
:: Run rundll32 printui.dll PrintUIEntry /in /y /n\client1printer1 if they said yes to default printer
Above is the code in question to give more context, this post gave me the command I needed to install printers of batch, as well as this
Its possible I messed up a variable since I’m new to batch, but am unsure where I went wrong in this script.