Announcement

Collapse
No announcement yet.

Shell As Admin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shell As Admin

    I'm running a free OCR program called tesseract.exe via SHELL from a PowerBASIC app. Tesseract runs without error but won't create the expected output text file.

    If I run the console version of tesseract.exe As Admin (through the start menu), it will successfully create the expected output text file.

    So my question is how to run tesseract.exe As Admin from within my PowerBASIC app.

  • #2
    You could try: ShellExecute 0, "runas", "myProg.exe", strParameters)

    https://docs.microsoft.com/en-us/win...-shellexecutea

    runas
    Launches an application as Administrator. User Account Control (UAC) will prompt the user for consent to run the application elevated or enter the credentials of an administrator account used to run the application.

    EIther that or a suitable manifest so that the whole application runs with admin privileges?

    Comment


    • #3
      Howdy, Stuart!

      Thanks very much for the reply.

      If I went the manifest route, I didn't think it's privileges would apply to the secondary app opened with ShellExecute. You're saying it would?

      Comment


      • #4
        Yes it does.

        Comment


        • #5
          Yes it does.
          As documented ...

          https://docs.microsoft.com/en-us/win...2/shell/launch

          (find "runas" on that page)
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Dale

            Comment


            • #7
              Child processes inherit the context of the starting process.
              <b>George W. Bleck</b>
              <img src='http://www.blecktech.com/myemail.gif'>

              Comment


              • #8
                Hello Gary
                Hello Stuart
                I'm having the same problem as Gary.
                I studied Stuart's answer.
                I see this answer satisfies Gary, but I don't understand how
                run this command with shellexecute in a program.
                Can you tell me how to do it:
                I have the french file "dotro.bmp" in c:\entree and I would like to convert it to "docto.txt" in c:\sortie
                The program is located here:
                C:\Program Files\Tesseract-OCR\tesseract.exe

                What should I write in command line.
                I would like to tell you a lot in advance.

                Christian Doris
                Attached Files

                Comment


                • #9
                  This works for me:
                  '
                  Code:
                  #COMPILE EXE
                  #DIM ALL
                  %UNICODE=1
                  #INCLUDE ONCE "WIN32API.INC"
                  FUNCTION PBMAIN() AS LONG
                      LOCAL hInst AS DWORD
                      hinst = ShellExecute( 0, "runas", $DQ & "C:\Program Files\Tesseract-OCR\tesseract.exe" & $DQ, "c:\entree\Docto.bmp c:\sortie\Docto","",0)
                      IF hInst > 41 THEN
                          ? "Success"
                      ELSE
                          ? "Error" & STR$(hInst)
                      END IF
                  END FUNCTION
                  '
                  Point Vision Calals-Marck
                  460 Avenue de Verdun, 62730 Marck

                  Motif de consultation

                  Choisissez un motif

                  Consultation d'ophtalmologie
                  Injection intravitréenne (IVT)
                  Chirurgie de la cataracte


                  Note:
                  Default is the .txt extension so don't include it in the output file name.

                  Comment


                  • #10
                    Thank you very much Stuart for your answer.
                    I deduce that tesseract_OCR, a program I didn't know, works wonderfully.
                    I didn't know the syntax of "ShellExecute(...)"; so far i am using shell command xxx,0.
                    I tested your program and failed to use it because my computer says "unauthorized" in the control of
                    the use of certain unrecognized software (Eset anti-virus or firewall?): I will have to explore this track.

                    I reinstalled the tesserac-OCR program and the languages ​​(French here).
                    I did some tests with

                    command line : call "c:\program files (x86)\tesserac-OCR" c:\input\docto.bmp c:\output\docto

                    and it works perfectly.

                    To exploit screenshots of the web, I frequently use notepad,
                    but this way of proceeding is not suitable for capturing the lines of popups.
                    With a bmp-image delimited copy, then an OCR treatment, I thus obtain the lines of the popups.

                    Thanks again.
                    Greetings from Burgundy.
                    Christian

                    Translated from French by google translate

                    Comment


                    • #11
                      Originally posted by Christian Doris View Post
                      To exploit screenshots of the web, I frequently use notepad,
                      As an aside to this thread:
                      As a developer, I'd strongly recommend you get a good text editor rather than using Notepad.
                      Things like:
                      • viewing all characters including CR,LF,TAB,space
                      • editing in column mode
                      • very powerful search and replace using complex expressions
                      • etc, etc
                      make such as move very worthwhile for anyone doing development, especially if you sometimes need to work with different formats of text files.

                      Personally, I recommend Noetpad++ https://notepad-plus-plus.org/ but there are other alternatives.

                      Comment


                      • #12
                        Hello Stuart

                        I expressed myself badly in my message: I wrote "notepad" but I thought
                        "CLIPBOARD GET TEXT TO VARIABLE", which I use in my programs.

                        After adpoting good compatibility (Windows 7), tessaract works fine.
                        With notepad++ the result appears in several lines unlike notepad.

                        Thanks for the advice to use notepad++:
                        I'm 76 years old and old habits are tenacious.
                        Recently I adopted notepad++.
                        Among all its features that I discover, I particularly appreciate the possibility open multiple files simultaneously as well as autocomplete.

                        In the end, the combination of a BMP screenshot and tesseract, makes it possible to copy popup menus from a popup in a text file


                        Christian

                        Translated from French by google translate

                        Comment


                        • #13
                          IDM UltraEdit as an editor.
                          <b>George W. Bleck</b>
                          <img src='http://www.blecktech.com/myemail.gif'>

                          Comment


                          • #14
                            Originally posted by George Bleck View Post
                            IDM UltraEdit as an editor.
                            Notepad++ does all I need it to, and its price (free) sure beats UltraEdits $80 PER YEAR!

                            Comment


                            • #15
                              I own the legacy pay-once lifetime update of both UltraEdit and UEStudio. I've used both N++ and UE and I've found UE has MANY more capabilities that I routinely take advantage of.

                              Apparently N++ worked for you; It didn't for me.
                              <b>George W. Bleck</b>
                              <img src='http://www.blecktech.com/myemail.gif'>

                              Comment


                              • #16
                                Originally posted by Stuart McLachlan View Post

                                Notepad++ does all I need it to, and its price (free) sure beats UltraEdits $80 PER YEAR!
                                We deploy NotePad++ on out servers to use for plain text chores, but on my dekstop/laptop, it's UltraEdit. I've been using it since it was shareware; the ability to edit huge files is often handy.
                                Real programmers use a magnetized needle and a steady hand

                                Comment


                                • #17
                                  Originally posted by Bud Durland View Post

                                  We deploy NotePad++ on out servers to use for plain text chores, but on my dekstop/laptop, it's UltraEdit. I've been using it since it was shareware; the ability to edit huge files is often handy.
                                  How huge? Notepad++ 8.2: Release Notes:
                                  "This release focuses on the management of large files: not only 2GB files size restriction has been removed from Notepad++ 64-bit binary, but also the loading and editing of large files (200MB) performance have been improved for both 32-bit and 64-bit binaries considerably."

                                  Comment


                                  • #18
                                    Originally posted by Stuart McLachlan View Post

                                    How huge?
                                    I don't keep a record, but I quite regularly have to work with translated SQL log trace files that exceed 300MB, so I guess it depends on your definition of huge. I do recall opening a file > 1gb a few years ago, but not much detail about it. If NP++ is working for you, great, I'm not looking to convince anyone to switch. I suspect there is a 90% +/- overlap in functional capability between the two. I like UE. It does everything I need, the bundle I license (UE and their compare tool), is well under $100/yr is very affordable for me, especially for 5 machines, with full tech support & automatic updates.

                                    Besides, I'm too old and tired to spend a lot of time tweaking a new editor to "work the way an editor is supposed to work"

                                    Real programmers use a magnetized needle and a steady hand

                                    Comment


                                    • #19
                                      I've opened multi-hundred GB files with UE and it is quite fast to open. Granted, jumping around takes a few to catch up, but it is very functional.
                                      <b>George W. Bleck</b>
                                      <img src='http://www.blecktech.com/myemail.gif'>

                                      Comment


                                      • #20
                                        I just wanted a block of text from a copy protected PDF, so I used Irfanview to capture the block as an image and saved it to a file.
                                        Then I wrote a simple little application to OCR any image file dropped on it , based on the code posted earlier in this thread.
                                        I've posted it in the Source Code forum:
                                        https://forum.powerbasic.com/forum/u...act#post817168

                                        Comment

                                        Working...
                                        X