Variable output is being truncated
Moderator: DosItHelp
-
- Posts: 2
- Joined: 18 Aug 2011 14:09
Variable output is being truncated
I'm writing a bat file to allow users to select printers to install. The black and white printers all have B&W in their name. The variable looks something like this: set printername=printer_name_b&w. The problem is that the output from the variable keeps dropping the "&w". Is there any way I can force the bat file to keep the "&w" or is it just easier to drop the & in the printer names?
Re: Variable output is being truncated
Code: Select all
@echo off
rem method 1
set "printername=printer_name_b&w"
echo "%printername%"
rem method 2
set "printername=printer_name_b^&w"
echo %printername%
rem method 3
setlocal enabledelayedexpansion
set "printername=printer_name_b&w"
echo !printername!
pause
-
- Posts: 2
- Joined: 18 Aug 2011 14:09
Re: Variable output is being truncated
Those two options worked great. Thank you Batcher.