Call me...




Sunday, August 19, 2018

Powershell TWAIN / scan from USB

This is just me being lazy, really...
  1. Plug in USB scanner...
  2. Start Button
  3. Open the 'Devices and Printers' applet
  4. Find the scanner
  5. Right-Click, and 'Start a Scan'

Or -
Write something that will find the scanner, and open the 'Start a Scan' window, when the script is ran...


I enabled the Quick Launch bar, and have this in there as a shortcut - I just changed the icon to a 'scanner'. (from here: %SystemRoot%\System32\SHELL32.dll)


This is the command for the shortcut...
Target:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe –NoProfile -windowstyle hidden -file "C:\Users\Rich\PSScripts\StartScan.ps1"

This line can be ran, to discover the 'Device description' for your device...
(gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)}).Description

Here is the scripts text:
$DeviceDesc = "CanoScan"
$FindTWAIN = (gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)} | Where-Object {($_.Description  -match $DeviceDesc)})
If ($FindTWAIN.Name -match $DeviceDesc){
$DeviceID = ($FindTWAIN.DeviceID).Replace("\","#")
$ClassGuid = $FindTWAIN.ClassGuid
$FullCommand = "`"C:\WINDOWS\system32\rundll32.exe`" fdprint,InvokeTask /ss `"\\?\"
$Params = "`"\\?\"+$DeviceID+"#"+$ClassGuid+"`""
& "C:\WINDOWS\system32\rundll32.exe" fdprint,InvokeTask /ss $Params
}

If ($FindTWAIN.Name -Notmatch $DeviceDesc){
#######################
$MsgBoxInfo = "$DeviceDesc device not found..."
[void] [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic")
[Microsoft.VisualBasic.Interaction]::MsgBox($MsgBoxInfo, "OKOnly,SystemModal,Exclamation", "Nothing Found.") | Out-null
 ## Out-null just supresses the 'ok' to the (ISE?) screen, after pressing the OK button.
#######################
}

23 comments:

  1. A 3D laser scanner can collect millions of data points within a second. It can collect highly accurate and measurable data every time. You can try this service on your construction and manufacturing business. 3D laser scanner Houston, Texas

    ReplyDelete
  2. I really love your blog.. Pleasant colors & theme. Did you develop this site yourself? Please reply back as I’m hoping to create my own blog and would like to know where you got this from or just what the theme is called. Appreciate it!
    free

    ReplyDelete
  3. The SD memory card is fast becoming the most popular. A great variety of devices use the SD memory card. This non-volatile flash memory format is used in portable devices such as digital cameras, handheld computers etc.
    https://www.hugdiy.com/sd-card-c-13

    ReplyDelete
  4. Nice,
    Any ideas on how to look at other TWAIN / WIA devices?
    Sometimes the device is connected via Ethernet / WiFi.

    ReplyDelete
    Replies
    1. Unfortunately - I don't have any such equipment to play with - So...
      No - I have no idea.

      Delete
  5. Truly accommodating Web journal simply shared much appreciated and I checked more related themes in laser scanning, reverse engineering, pointcloud. Keep updating. 3d laser scanner Denver, Colorado

    ReplyDelete
  6. valuable blog,Informative content...thanks for sharing, Waiting for the next update...
    Cyber Security Course in Chennai
    Cyber Security Training in Chennai

    ReplyDelete
  7. This is often at the same time a good present that many of us seriously enjoyed browsing. It's not at all on a daily basis which i provide the likeliness to check something. digital marketing

    ReplyDelete
  8. First, they help them locate the best paths for telecommunications equipment via topographical surveying. Second, they help them to ensure the equipment coheres with its environment. Third, scan data can be helpful for maintenance, troubleshooting and rerouting paths of line. 3d laser scanning survey Sydney

    ReplyDelete
  9. Top Notch article, it is particularly valuable! I unobtrusively began in this, and I'm transforming into more familiar close by inside the focal point of it better! Delights, articulation war more and hauling continuing extraordinary! https://crackdj.com/card-recovery-full-crack-key/

    ReplyDelete
  10. Free Recuva Download Full Version Howdy, I see as cognizant part concentrating on this text a delight. it's miles really pleasurable to prepared and fascinating and profoundly tons looking take care of to perusing extra of your trademark..

    ReplyDelete
  11. Happy Independence Day! On the eve of INDEPENDENCE DAY, lets salute and remember the soldiers who sacrificed their lives to protect our nation..Independence Day Urdu Quotes

    ReplyDelete