UAC Prompt using code

Posted on 2012-08-23
Last Modified: 2012-09-17
I am writing a program in that requires running an external program (psexec.exe).
But I need to have my program prompt for Admin credentials and then pass them through to open the psexec.exe command as the admin from UAC.
I am unable to pass the credentials using the plain Process.Start syntax due to security reasons (we don't want to pass the password that way.)
Instead of using something like the following code -
Process.Start("cmd.exe", " /k PSExec.exe \\" & computername.text & " cmd.exe"
which will call the cmd to run psexec (but needs to have it loaded as Admin).

Sorry for the confusion on the information - but short story I need a way to prompt (through my VB program) for User Account Control prompt to get an admin to input Admin credentials and then open and execute a command & psexec.

Please let me know if anyone has any advice.  Thank you.
Question by:afrpa
    1 Comment
    LVL 12

    Accepted Solution


    Try anyone of the following steps:

    1) You can add manifest file for psexec.exe and set requestedExecutionLevel as requireAdministrator.
    2) In cmd.exe pass parameter as runas \administrator.
    3) Update registry.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now