Save first match in variable, ignore rest
Posted: 03 Dec 2016 08:42
Hi,
I want to set the default (local) printer in a script. Basically, what I do is checking the default printer device.
If it's "Adobe PDF", I want to look for another device and make it the default printer. I've got that part of the script already.
The linegets me all installed printers. I'd like to take the first match/line only and assign it to a variable.
Is there a straightforward method without writing to temporary files etc.?
I want to set the default (local) printer in a script. Basically, what I do is checking the default printer device.
If it's "Adobe PDF", I want to look for another device and make it the default printer. I've got that part of the script already.
The line
Code: Select all
wmic Printer where name!='Adobe PDF' get name /value | findstr /r /v "^$"
Is there a straightforward method without writing to temporary files etc.?