Some people have multiple scanners and use different scanners for different things. Having to choose a scanner every time is a real pain. Here’s how to solve that.
One of the strengths of CmdTwain is being able to use it in a batch file or run it from some other program to scan a document simply and without having to manually key in settings every time. It works well with a single document scanner. It got messier when, for some people, the camera was the default scanning device (and every scan resulted in a picture of the person trying to use the scanner rather than the document in the scanner). That got solved by fixing the default TWAIN source (use any program that allows setting this – eg “CmdTwain /SOURCE” – they all pop up a window and let you pick whichever device should be your default scanning device).
BUT, I had a request from someone with multiple scanners and who uses different scanners for different things. He needed to change the default with each scan. Given the benefit of CmdTwain is not having to enter a stack of settings each time, having to pick a scanner from a GUI window each time was very much counter to what he was after.
He wanted to be able to add something to the batch file he was using that would automatically choose the default TWAIN device (scanner). He could have a different batch file for each task and each would just use the proper scanner. There wouldn’t be any need for someone to choose one every time.
The default is saved in a Windows registry setting so anything that can change the setting will allow you to choose the correct scanner. It doesn’t have to be done with you clicking in a GUI every time.
One simple solution would be to have a registry file for each device and simply “run” the relevant file each time. This would update the setting and then do the scan.
Batch files don’t have easy access to the registry; but VBScript does so here is another option – a VBScript that you can include in a batch file. The link is to a ZIP so extract the “.vbs” file and save it where your batch file can find it. Add a line to your batch file to use it and you’re done.
It works like this:
SetTwainSource.vbs driver
If you run it without including a driver on the command line it will tell you which driver is currently the default one.
If you run it with “/?” instead of “driver” it will list the drivers installed on your computer so you can see what your choices are.
As always, the software is offered as is. Test it for your circumstances before using it in a production environment. VBScript is human-readable so feel free to see what it does (open with Notepad) and customise it if you like.