Attempting to write a .bat script for reinstalling printers

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.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<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>
<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.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật