Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Execute File as Admin

Author
Message
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 2nd Jun 2012 21:52
Hi there. So I need to run an executable from my program and I need to run it as an administrator. The program launching the second program will not have been run as an administrator. I don't mind that the program will presumably have to request permission from the user to launch the second program in admin mode. However I can't work out how to get it to even request the launch as an administrator. So far I've been playing around with the execute file command but I'm not sure if there are any other options for this.

Anyhow any advice on how I might be able to do this would be greatly appreciated. Thanks in advance!

Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 2nd Jun 2012 22:27
If you add "runas /user:Administrator " before the command you are trying to execute it should work. With execute file this will mean that "runas" is the file to be executed, and the arguments are "/user:Administrator <cmd>".

[b]
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 2nd Jun 2012 23:02
Thanks Diggsey. Just had a try and what I'm getting is a cmd terminal asking for a password. However when I type, it doesn't appear to accept any input (although cmd passwords often don't appear to anyway) but it doesn't accept my password or blank. Any idea what might be going on given that I am an administrator? Also do you think there is any possibility of getting it to display the usual Yes/No messagebox instead of the cmd terminal?

Anyhow thanks again for your help.

GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 3rd Jun 2012 07:27
http://forum.thegamecreators.com/?m=forum_view&t=193024&b=1

Here is my thread where I needed this. I downloaded ResourceTuner and added a line into the EXE manifest that forced it to ask for admin when run.

Hope that helps.
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 3rd Jun 2012 09:58
Hey GIDustin, thanks for the suggestion! That works great now. Just for the benefit of anyone else trying to do this, the line I changed using the ResourceTuner was the line in the manifest that read like this:

<requestedExecutionLevel level="asInvoker" uiAccess="false"/>

and I changed it to this:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>

Thanks again .

Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 3rd Jun 2012 10:19
OK sorry for the double post on this but I've just encountered another problem to do with this. You see, whenever I launch the application as admin from another application, it causes the DBP program to crash with the "sprite does not exist at line X" error.

I've encountered this problem before when an application has been running in "Fullscreen" mode and you try and open another window in front of it. However this application is running as "Windowed Fullscreen" and so the error doesn't usually occur. The problem seems to relate to the message box that pops up and asks for the users permission. I've tested my application in a variety of different modes including Windowed and I've found that whenever this message box displays, regardless or not of whether is was generated by the program itself trying to launch another application, the DBP application immediately crashes with this sprite error. Does anyone have any idea why this might be happening and how I can fix it? Thanks!

GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 3rd Jun 2012 17:19
The UAC window runs fullscreen, and therefore dumps the media of all your programs. There currently is no way to avoid it.

See my other other thread:
http://forum.thegamecreators.com/?m=forum_view&t=192885&b=1

I am trying to get IanM to create a function that will let us know when this happens so that we can re-create our images/sprites/etc.
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 3rd Jun 2012 18:27
Thanks GIDustin, that's very interesting to know. So my game will probably crash on Alt-Ctrl-Del as well then... Well thanks for telling me but I can't really see a way around this. I'm glad IanM thinks he has a solution but it looks like it's been a while since that post was updated on any progress.

Just wondering, did you encounter this problem with the UAC window then? It's just that in your other post, you talk more about Alt-Ctrl-Del.

GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 3rd Jun 2012 22:03
Both CTRL+ALT+DEL and UAC. Also, some screensavers cause the problem as well.

Login to post a reply

Server time is: 2026-07-07 22:23:25
Your offset time is: 2026-07-07 22:23:25