July 13, 2020
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 windows.
July 13, 2020
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 && %s\"".format(getcwd(), x).to!wstring, null, SW_HIDE).WaitForSingleObject(WAIT_TIMEOUT));

runas("netsh winhttp set proxy 127.0.0.1:9666")
July 13, 2020
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 => 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 set proxy 127.0.0.1:9666")

Can you put it into a small dub package?
July 13, 2020
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 = 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 set proxy 127.0.0.1:9666")
>
> Can you put it into a small dub package?

I do not know how to do that. Observation: Remove the code .WaitForSingleObject (WAIT_TIMEOUT)
July 14, 2020
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 set proxy 127.0.0.1:9666")

Use backticks instead of doublequotes, than you don't have to escape the doublequotes within the string. So:

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);

1 2
Next ›   Last »