Using Shellexecute to start a program

  • Hello


    How can i use ShellExecute command to start an application. Since the application as to be run in administrator mode, i suppose that i need to pass a Vbyes parameter to the comnmand line. When started manualy, Windows open a secutity box and ask if i approved it.


    The application is use for a text capture process
    name is: Hypersnap6.exe
    Directory: "c:\Program Files (x86)\Hypersnap 6\"


    I did use before the shell() command, but it doesn't work anymore when the targeted application is under administrator mode


    Any help appreciated


    Martin
    Montreal, Canada

  • Re: Using Shellexecute to start a program


    I've re-opened this thread.


    If anybody is familiar with MrExcel then they will realise that they are having a lot of problems over there at the moment.


    I think this might be the reason that Martin has cross-posted.:)

    Boo!:yikes:

  • Re: Using Shellexecute to start a program


    Solutioned....


    Thank you Norie, your a great man. Sol


    Yes i had problem with MrExcel site yesterday, i taught it was another problem that i had. I was in hurry to solution that one. First time that i post on multiple forum. I had to be up and running fast. Did learn my lesson.


    I did found the solution witch consist to give Excel an administrator right also.


    1- Right click on Excel icon, select compatibility, Priviledge level, execute as an administrator
    2- close and re-open Excel
    3- From the opened Excel page, load the worksheet
    4- Since my Excel worksheet was starting two others .exe application, i did give them also the administrator right in their property.


    et voila


    I did found that Starting directly my worksheet with is icone ( next to Excel in start menu), won't work as my worksheet will not get is administrator right


    Martin

  • Re: Using Shellexecute to start a program


    Martin


    No problem.:)


    If you do cross-post then if you provide a link to the other forum then most people don't mind.


    Oh, and thanks for posting the solution - one thing I don't like is when people just reply saying they've solved their problem without further details.:dolphin:

    Boo!:yikes:

  • You know how maybe once a year you have one of those coding experiences that make you literally shout for joy? This thread gave me one.

    I read and tried the info from maybe 100 URL's on Shell, ShellExecuteA, ShellExecuteExecute to no avail. I used a manual work around for years until I herein found mtheriault's solution to set Excel to admin mode. I was so thankful for this long-sought solution that I joined the forum just to possibly assist others googling similar keywords to mine to find help on this topic.


    I was using the following type of code (mind you this is a cut out from 100's of code lines across 10 subs and 6 functions) and it worked fine for calling a program at C:\Jts\tws.exe but not for the below illustrated "C:\Program Files (x86)\Value Line Publishing\Value Line Investment Survey\VLIS.exe". I suspected it had something to do with the 32 vs 64 bit nature of the programs, but now doubt this has anything to do with it.


    I would activate the desired program (TWS or VLIS) so as to apply an AutoHotKey (AHK) script, however the AHK script required that I set the VLIS.exe to run as Admin (Admin mode not required for TWS, hence my remaining slight suspicion of 32 vs 64 bit factoring in). Once I did set VLIS to Admin, AHK ran fine but shell wouldn't. I only code once a week as a hobby and so did not connect the VLIS.exe Admin setting to the shell failure and based on the error message (Run-Time error '5': Invalid procedure call or argument) I thought the shell failure was based elsewhere. Naturally any documentation I looked at for a solution did not touch on mtheriault's method.


    Frankly, I'm in awe of how mtheriault happened figured this out and very grateful to norie for re-opening the thread, mtheriault for coming back and sharing his solution, and norie again for encouraging such good solution-sharing practices, all of which brought me to contribute my 2 cents here at OzGrid.com, for which I am also thankful.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!