Re: How can I make executeShell ask for Admin Elevation?

2020-07-14 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Monday, 13 July 2020 at 19:32:33 UTC, Marcone wrote: alias runas = compose!(x => to!bool((cast(int) x) > 32), x => ShellExecute(null, "runas", "cmd", cast(wchar*) "/c \"cd /d %s && %s\"".format(getcwd(), x).to!wstring, null, SW_HIDE).WaitForSingleObject(WAIT_TIMEOUT)); runas("netsh winhttp

Re: How can I make executeShell ask for Admin Elevation?

2020-07-13 Thread Marcone via Digitalmars-d-learn
On Monday, 13 July 2020 at 12:28:24 UTC, aberba wrote: On Monday, 13 July 2020 at 00:57:02 UTC, Marcone wrote: On Sunday, 12 July 2020 at 02:10:11 UTC, Marcone wrote: I don't want start program with admin elevation, but ask user for admin permission when some function is called. alias runas =

Re: How can I make executeShell ask for Admin Elevation?

2020-07-13 Thread aberba via Digitalmars-d-learn
On Monday, 13 July 2020 at 00:57:02 UTC, Marcone wrote: On Sunday, 12 July 2020 at 02:10:11 UTC, Marcone wrote: I don't want start program with admin elevation, but ask user for admin permission when some function is called. alias runas = compose!(x => to!bool((cast(int) x) > 32), x => ShellE

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn
On Sunday, 12 July 2020 at 02:10:11 UTC, Marcone wrote: I don't want start program with admin elevation, but ask user for admin permission when some function is called. alias runas = compose!(x => to!bool((cast(int) x) > 32), x => ShellExecute(null, "runas", "cmd", cast(wchar*) "/c \"cd /d %s

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn
On Sunday, 12 July 2020 at 21:50:06 UTC, Ali Çehreli wrote: On 7/11/20 7:10 PM, Marcone wrote: [...] Here is a hacky solution that attempts the command and fails back to asking the password. It should work on POSIX systems. (Tested on Linux.) [...] I need for Windows, it not work on wind

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Ali Çehreli via Digitalmars-d-learn
On 7/11/20 7:10 PM, Marcone wrote: I don't want start program with admin elevation, but ask user for admin permission when some function is called. Here is a hacky solution that attempts the command and fails back to asking the password. It should work on POSIX systems. (Tested on Linux.) im

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn
On Sunday, 12 July 2020 at 17:28:01 UTC, Kagamin wrote: I mean runas your own program. I need a function that ask for admin at runtime only for one function

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Kagamin via Digitalmars-d-learn
I mean runas your own program.

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn
On Sunday, 12 July 2020 at 17:19:08 UTC, Kagamin wrote: Well, you can elevate your own program and tell it to run that command, collect the result and send it back through e.g. shared memory. I don't want start with elevation, becouse program must be avaliable even user is not admin. Only ask

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Kagamin via Digitalmars-d-learn
Well, you can elevate your own program and tell it to run that command, collect the result and send it back through e.g. shared memory.

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn
On Sunday, 12 July 2020 at 02:10:11 UTC, Marcone wrote: I don't want start program with admin elevation, but ask user for admin permission when some function is called. How can I get return code ans stdout of this code: ShellExecute(null, "runas", "cmd", "/c netsh winhttp set proxy 127.0.0.1:

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn
On Sunday, 12 July 2020 at 12:31:17 UTC, Kagamin wrote: You call ShellExecute with "runas" verb: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea I need return code and stdout.

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Marcone via Digitalmars-d-learn
On Sunday, 12 July 2020 at 12:31:17 UTC, Kagamin wrote: You call ShellExecute with "runas" verb: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea Please give me a litle simple example ruining this command: "netsh winhttp set proxy 127.0.0.1:"

Re: How can I make executeShell ask for Admin Elevation?

2020-07-12 Thread Kagamin via Digitalmars-d-learn
You call ShellExecute with "runas" verb: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea

How can I make executeShell ask for Admin Elevation?

2020-07-11 Thread Marcone via Digitalmars-d-learn
I don't want start program with admin elevation, but ask user for admin permission when some function is called.