+ Reply to Thread
Results 1 to 5 of 5

Windows 7: How to run an "Elevated" command line?

  1. #1
    Registered User
    Join Date
    09-25-2008
    Location
    Winnetka, CA
    Posts
    83

    Windows 7: How to run an "Elevated" command line?

    In my VBA procedure, I need to run the app "Skitch" and use it to open a JPEG file. This is the command I've been using:

    Please Login or Register  to view this content.
    ...where "aPic" is the path and filename.

    After some experimenting, I think I need to run the command as if it were in an Elevated Command window (in other words, run it "as Administrator"). How can I do that?

    Thanks.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Windows 7: How to run an "Elevated" command line?

    Hi shawnvw,

    I think you need 'ShellExecute'. I have run it with .bat files, but I have never tried it with .exe files directly. In Vista (32 bit and 64 bit), UAC asks for permission to run as administrator, after the command is invoked. See my attached file with code to follow, that deletes the print queue. You may be able to adapt the code to your needs.

    Lewis

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-25-2008
    Location
    Winnetka, CA
    Posts
    83

    Re: Windows 7: How to run an "Elevated" command line?

    I tried this, based on a similar example I found:

    Please Login or Register  to view this content.

    However, it once again opens Skitch with a "new" image, not the one I specified, which suggests that it's not Elevating.

    Is there something missing from my code that would Elevate it?

    When the app is running, is there a way to confirm that it's running Elevated?

    Thanks again.

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Windows 7: How to run an "Elevated" command line?

    The following worked for me:
    Please Login or Register  to view this content.
    Vista asks me if I want to run this program as Administrator. The only way around the prompt that I know of on Vista is to turn UAC off and reboot the computer.

    The following is the Microsoft specs with 'runas' undocumented:
    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

    See also:
    http://ss64.com/vb/shellexecute.html

    The ss64 link states:
    The runas verb is undocumented but can be used to elevate permissions. When a script is run with elevated permissions several aspects of the user environment may change: The current directory, the current TEMP folder and any mapped drives will be disconnected.
    Lewis

  5. #5
    Registered User
    Join Date
    09-25-2008
    Location
    Winnetka, CA
    Posts
    83

    Re: Windows 7: How to run an "Elevated" command line?

    When I do that, it asks me for permission to run, so I know it's running Elevated. Thanks.

    Unfortuantley, having the picture open still seems to only work part of the time. Sometimes it opens a picture I viewed in a previous session! This means my problem is something else entirely.




    Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create a Command Button to "Save As" and "Close" an Excel Workbook
    By thedunna in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-26-2013, 05:38 PM
  2. Replies: 4
    Last Post: 02-03-2008, 05:11 PM
  3. How to change a Command Button caption from "Enable" to "Disable"?
    By Infinity in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2007, 12:14 AM
  4. [SOLVED] Running command line "aplication"
    By dim in forum Excel General
    Replies: 0
    Last Post: 10-14-2005, 06:05 AM
  5. Is there a command line "switch" To close Excel
    By Randy Wayne in forum Excel General
    Replies: 2
    Last Post: 08-22-2005, 05:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1