Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

How to "Start Application" as Administrator?

If you have a question or need help, this is the place to be.
Post Reply
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

How to "Start Application" as Administrator?

Post by kkl »

Is there a way for "Start Application" to launch the target program with administrative privileges? I have a short batch script saved as a .cmd file. It does not work correctly when launched by Start Application. I've also found that it is unsuccessful when run from a standard CLI session, but works correctly when run from a CLI started with "Run as Administrator". The only command being used is devcon.exe (enable and disable). Can someone help? Thanks.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: How to "Start Application" as Administrator?

Post by Pako »

It is strange that no one answered you.
It's so easy:
1. Here you download PsTools by Mark Russinovich
2. The downloaded file unzip and the file psexec.exe put to the directory where you have EventGhost installed
3. Into your macro insert Python script action with this code

Code: Select all

appPath = 'notepad.exe'

from subprocess import Popen, SW_HIDE
args = ['psexec.exe','-u','<USER>','-p','<PASSWORD>']
args.append(appPath)
Popen(args, creationflags = SW_HIDE, shell = True)
4. Instead of notepad.exe enter the path to your exe file
5. Of course, you also need to replace the strings <USER> and <PASSWORD>

Pako
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: How to "Start Application" as Administrator?

Post by kkl »

Pako, thanks very much for taking the time to detail how to do this. Your example appears to work. Easy? Only for someone with superior knowledge!
Siutsch
Experienced User
Posts: 51
Joined: Wed Apr 28, 2010 6:53 am

Re: How to "Start Application" as Administrator?

Post by Siutsch »

Hi.

I have the same problem after changing vom Windows 7 to Windows 8.1

Can it be that the script only works for programs (*.exe) but not for Batch Scripts (*.cmd)?

Siutsch.
bskchaos
Experienced User
Posts: 56
Joined: Tue Mar 25, 2008 3:04 pm

Re: How to "Start Application" as Administrator?

Post by bskchaos »

You can try creating a Task with admin privileges and then create a shortcut to start the task.
schtasks.exe /run /tn "task"
kkl
Experienced User
Posts: 317
Joined: Wed May 04, 2011 9:32 pm

Re: How to "Start Application" as Administrator?

Post by kkl »

bskchaos wrote:You can try creating a Task with admin privileges and then create a shortcut to start the task.
schtasks.exe /run /tn "task"
A belated thank you very much. I just tried your solution and it works great.
Post Reply