Bamfkin

ExecuteShell/Run do not run as administrator

5 posts in this topic

I am on Windows 10.

I've been trying to test using tesseract in AutoIt but it never runs tesseract as administrator. I've run the script as Administrator, I've tried RunAs using system and administrator accounts.

The reason why I am saying this is the issue is because tesseract does not create an output file unless I run it from an admin command prompt. Running it from a non-admin command prompt produces the same situation I'm seeing from AutoIt - everything runs successfully except creating the output file.

This is the shell execute code I'm running.

#include-once
#include <Tesseract.au3>
#include <Date.au3>

$windowTitle = "*new 1 - Notepad++"
$scale = 2
$left_indent =53
$top_indent =98
$right_indent =(880-224)
$bottom_indent =(560-118)

$capture_filename = $tesseract_temp_path & StringReplace(_NowDate(), "/", "_") & "_" & StringReplace(StringReplace(_NowTime(), ":", "_"), " ", "_") & ".tif"
_FileCreate($capture_filename)
$output_filename = StringLeft($capture_filename, StringLen($capture_filename) - 4)

CaptureToTIFF($windowTitle, "", "", $capture_filename, $scale, $left_indent, $top_indent, $right_indent, $bottom_indent)
ShellExecuteWait(@ProgramFilesDir & "\Tesseract-OCR\tesseract.exe", $capture_filename & " " & $output_filename)

Im piggy backing off of the tesseract.au3 right now but all of this was done because it wasn't working (after I updated to correct file paths)

Anyone had this issue and/or know of a way to work around this? 

Share this post


Link to post
Share on other sites



Either I'm blind or there is no edit button... but I'm open to other suggestions if someone doesn't believe it to be a permissions issue.

Share this post


Link to post
Share on other sites

I had not. Just tried it and nothing new. Creates a .tif but no output file from tesseract.

I printed the ShellExecuteWait as

ConsoleWrite(@ProgramFilesDir & "\Tesseract-OCR\tesseract.exe " & $capture_filename & " " & $output_filename & @CRLF)

Then copy/paste that into a command prompt.. put quotes around all 3 paths and it creates the output file. Is something wrong with how Im using ShellExecuteWait? Do I need to somehow inherently put quotations marks within it?

It would be great if I could get the command prompt to pause when it pops up from ShellExecuteWait so I could see what is being executed... anyone know how to make that happen?

Share this post


Link to post
Share on other sites

So, after that post I moved my tesseract install to directly into the C: drive and where I was saving my files directly to the C: drive. It works now. So either it's a permission issue with Program Files x86 or ShellExecute needs me to put quotation marks into the string (which Im not sure how to do in AutoIt; thats why I just moved everything).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now