<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API)]]></title><description><![CDATA[<p dir="auto">I’m kind of stuck on this issue. Here’s the context:<br />
Notepad++ launches WinGup as admin for installing/updating Plugins, then it quite. After the operations, WinGup  will relaunch Notepad++. The problem is since  WinGup has the privilege right, any process launched by WinGup will inherent the elevation.</p>
<p dir="auto">Is there any trivial way in win32 API to get the hack down?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/16720/launch-a-no-elevated-process-from-an-elevated-process-in-an-easy-way-win32-api</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 02:36:26 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/16720.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 29 Nov 2018 13:14:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Tue, 04 Dec 2018 21:40:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a></p>
<p dir="auto">Sorry, I was wrong. I have tested with the wrong debug binary which hadn’t contained your last <em>ShellExecute</em> patch. Sorry for the inconvenience.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37153</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37153</guid><dc:creator><![CDATA[dinkumoil]]></dc:creator><pubDate>Tue, 04 Dec 2018 21:40:38 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Tue, 04 Dec 2018 21:14:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a></p>
<p dir="auto">I have tested the <em>ShellExec</em> one-liner solution more thoroughly and noticed the following:</p>
<p dir="auto">If a user wants to install a plugin, an UAC dialog pops up and requests for confirmation. After the plugin is installed Notepad++ restarts. So far so good.</p>
<p dir="auto">If the user now wants to install another plugin, the plugin gets installed <strong>without</strong> an UAC dialog poping up, it is just done and Notepad++ restarts after that.</p>
<p dir="auto">It seems like though Notepad++ obviously runs with user rights, it actually does not.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37151</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37151</guid><dc:creator><![CDATA[dinkumoil]]></dc:creator><pubDate>Tue, 04 Dec 2018 21:14:40 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Sat, 01 Dec 2018 16:30:38 GMT]]></title><description><![CDATA[<p dir="auto">The solution of <a class="plugin-mentions-user plugin-mentions-a" href="/user/singhrajenm" aria-label="Profile: SinghRajenM">@<bdi>SinghRajenM</bdi></a> is tested and works fine! Merged into the master of wingup:<br />
<a href="https://github.com/notepad-plus-plus/wingup/commit/af34920693261307d34bb530622e6d70cbe875d2" rel="nofollow ugc">https://github.com/notepad-plus-plus/wingup/commit/af34920693261307d34bb530622e6d70cbe875d2</a></p>
<p dir="auto">Thank you <a class="plugin-mentions-user plugin-mentions-a" href="/user/singhrajenm" aria-label="Profile: SinghRajenM">@<bdi>SinghRajenM</bdi></a>  for your hint and your solution (again, besides of NSIS).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37070</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37070</guid><dc:creator><![CDATA[donho]]></dc:creator><pubDate>Sat, 01 Dec 2018 16:30:38 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Sat, 01 Dec 2018 14:14:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a> said:</p>
<blockquote>
<p dir="auto">I’ll try firstly One Line solution of <a class="plugin-mentions-user plugin-mentions-a" href="/user/singhrajenm" aria-label="Profile: SinghRajenM">@<bdi>SinghRajenM</bdi></a> .</p>
</blockquote>
<p dir="auto">Of course.</p>
<blockquote>
<p dir="auto">Wow, it’s miles and miles of codes</p>
</blockquote>
<p dir="auto">It’s not that bad, the absolutely core functionality is about to 90 lines of code which you can shorten even more.</p>
<blockquote>
<p dir="auto">for just preventing from elevation !</p>
</blockquote>
<p dir="auto">It’s not a “just”. For this functionality there is no ready-to-use Windows API. That the <code>ShellExecute</code> one-liner does the job is an undocumented feature and relies on the current implementation of <em>Explorer.exe</em>. And with this method it is not possible to start the unelevated process with parameters.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37059</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37059</guid><dc:creator><![CDATA[dinkumoil]]></dc:creator><pubDate>Sat, 01 Dec 2018 14:14:18 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Sat, 01 Dec 2018 12:49:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dinkumoil" aria-label="Profile: dinkumoil">@<bdi>dinkumoil</bdi></a><br />
Wow, it’s miles and miles of codes for just preventing from elevation !  I’ll try firstly One Line solution of <a class="plugin-mentions-user plugin-mentions-a" href="/user/singhrajenm" aria-label="Profile: SinghRajenM">@<bdi>SinghRajenM</bdi></a> .<br />
Thank you.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37058</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37058</guid><dc:creator><![CDATA[donho]]></dc:creator><pubDate>Sat, 01 Dec 2018 12:49:38 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Sat, 01 Dec 2018 09:20:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a></p>
<p dir="auto">In case it is important for you to be able to call Notepad++ with command line arguments - I’ve implemented the algorithm from my 2nd MSDN link provided above in C and wrapped it in a small demo program.</p>
<ul>
<li>It can start another program with the user rights of the desktop shell process if itself is elevated.</li>
<li>It can start another program with the same user rights that itself runs under if it is <strong>not</strong> elevated.</li>
<li>It can start another program with parameters.</li>
</ul>
<p dir="auto">Of course, it is not an oneliner and you have to change the implementation of error handling. The <em>GetFullPath</em> routine is not necessary.</p>
<p dir="auto">I compiled it with <em>MinGW</em>. It has to be linked against <em>Advapi32.lib</em> and <em>Kernel32.lib</em>.</p>
<pre><code>#define _WIN32_WINNT 0x0501
#define WIN32_LEAN_AND_MEAN
#define STRICT 1

#define _UNICODE
#define UNICODE

#include &lt;sdkddkver.h&gt;


/*******************************************************************************
Includes
*******************************************************************************/

#include &lt;windows.h&gt;

#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;



/*******************************************************************************
Prototypes
*******************************************************************************/

BOOL   RunAsDesktopUser (LPCWSTR szApp, LPWSTR szCmdLine, LPCWSTR szCurrDir, STARTUPINFO *si, PROCESS_INFORMATION *pi);
BOOL   RunLoweredProcess(LPCWSTR szApp, LPWSTR szCmdLine, LPCWSTR szCurrDir, STARTUPINFO *si, PROCESS_INFORMATION *pi);
BOOL   RunProcess       (LPCWSTR szApp, LPWSTR szCmdLine, LPCWSTR szCurrDir, STARTUPINFO *si, PROCESS_INFORMATION *pi);
BOOL   SetPrivilege     (HANDLE hProcessToken, LPCWSTR lpszPrivilege, BOOL bEnablePrivilege);
BOOL   IsElevatedToken  (HANDLE hProcessToken);
LPWSTR GetFullPath      (LPCWSTR szFilePath);




/*******************************************************************************
Main program
*******************************************************************************/

int wmain(int argc, WCHAR *argv[])
{
  LPWSTR              fullPath    = NULL;
  LPWSTR              commandLine = NULL;
  STARTUPINFO         si          = {0};
  PROCESS_INFORMATION pi          = {0};

  si.cb          = sizeof(si);
  si.dwFlags     = STARTF_USESHOWWINDOW;
  si.wShowWindow = SW_SHOWNORMAL;

  if ((fullPath = GetFullPath(L"%ProgramFiles(x86)%\\Notepad++\\notepad++.exe")) == NULL)
  {
    wprintf(L"File not found\n");
    goto cleanup;
  }

  commandLine = calloc(wcslen(fullPath) + 14, sizeof(*fullPath));
  wsprintf(commandLine, L"\"%s\" %s", fullPath, L"-multiInst");

  if (RunAsDesktopUser(fullPath, commandLine, NULL, &amp;si, &amp;pi))
  {
    WaitForSingleObject(pi.hProcess, INFINITE);

    if (pi.hThread != NULL)
      CloseHandle(pi.hThread);

    if (pi.hProcess != NULL)
      CloseHandle(pi.hProcess);
  }

cleanup:
  free(fullPath);
  free(commandLine);

  return 0;
}


BOOL RunAsDesktopUser(LPCWSTR szApp, LPWSTR szCmdLine, LPCWSTR szCurrDir,
                      STARTUPINFO *si, PROCESS_INFORMATION *pi)
{
  BOOL   bRetVal       = FALSE;
  HANDLE hProcessToken = NULL;

  // Retrieve process token of own process
  if (!OpenProcessToken(GetCurrentProcess(),
                        TOKEN_QUERY
                         | TOKEN_ADJUST_PRIVILEGES,
                        &amp;hProcessToken))
  {
    wprintf(L"OpenProcessToken failed, error code: %u\n", GetLastError());
    goto cleanup;
  }

  // Check if own process is elevated
  if (!IsElevatedToken(hProcessToken))
  {
    // Run process with user rights of own process
    if (!(bRetVal = RunProcess(szApp, szCmdLine, szCurrDir, si, pi)))
      goto cleanup;
  }
  else
  {
    // Add privilege SE_INCREASE_QUOTA_NAME to own process token
    if (!(bRetVal = SetPrivilege(hProcessToken, SE_INCREASE_QUOTA_NAME, TRUE)))
      goto cleanup;

    // Run process with user rights of desktop shell process
    if (!(bRetVal = RunLoweredProcess(szApp, szCmdLine, szCurrDir, si, pi)))
      goto cleanup;
  }

  bRetVal = TRUE;

cleanup:
  CloseHandle(hProcessToken);

  return bRetVal;
}


BOOL RunProcess(LPCWSTR szApp, LPWSTR szCmdLine, LPCWSTR szCurrDir,
                STARTUPINFO *si, PROCESS_INFORMATION *pi)
{
  // Start process with user rights of own process
  if (!CreateProcess(szApp,
                     szCmdLine,
                     (LPSECURITY_ATTRIBUTES) NULL,
                     (LPSECURITY_ATTRIBUTES) NULL,
                     FALSE,
                     0,
                     (LPVOID) NULL,
                     szCurrDir,
                     si,
                     pi))
  {
    wprintf(L"CreateProcess failed, error code: %u\n", GetLastError());
    return FALSE;
  }

  return TRUE;
}


BOOL RunLoweredProcess(LPCWSTR szApp, LPWSTR szCmdLine, LPCWSTR szCurrDir,
                       STARTUPINFO *si, PROCESS_INFORMATION *pi)
{
  BOOL   bRetVal            = FALSE;
  HWND   hShellWnd          = NULL;
  DWORD  dwShellProcessID   = 0;
  HANDLE hShellProcess      = NULL;
  HANDLE hShellProcessToken = NULL;
  HANDLE hPrimaryToken      = NULL;

  // Retrieve handle of desktop shell window
  if ((hShellWnd = GetShellWindow()) == NULL)
  {
    wprintf(L"GetShellWindow failed\n");
    goto cleanup;
  }

  // Retrieve process id of desktop shell window
  GetWindowThreadProcessId(hShellWnd,
                           &amp;dwShellProcessID);

  if (dwShellProcessID == 0)
  {
    wprintf(L"GetWindowThreadProcessId failed\n");
    goto cleanup;
  }

  // Retrieve process handle of desktop shell process
  hShellProcess = OpenProcess(PROCESS_QUERY_INFORMATION,
                              FALSE,
                              dwShellProcessID);

  if (hShellProcess == NULL)
  {
    wprintf(L"OpenProcess failed, error code: %u\n", GetLastError());
    goto cleanup;
  }

  // Retrieve process token of desktop shell process
  if (!OpenProcessToken(hShellProcess,
                        TOKEN_DUPLICATE,
                        &amp;hShellProcessToken))
  {
    wprintf(L"OpenProcessToken failed, error code: %u\n", GetLastError());
    goto cleanup;
  }

  // Duplicate process token of desktop shell process to a primary token
  if (!DuplicateTokenEx(hShellProcessToken,
                        TOKEN_QUERY
                         | TOKEN_DUPLICATE
                         | TOKEN_ASSIGN_PRIMARY
                         | TOKEN_ADJUST_DEFAULT
                         | TOKEN_ADJUST_SESSIONID,
                        NULL,
                        SecurityImpersonation,
                        TokenPrimary,
                        &amp;hPrimaryToken))
  {
    wprintf(L"DuplicateTokenEx failed, error code: %u\n", GetLastError());
    goto cleanup;
  }

  // Start process with user rights of desktop shell process
  if (!CreateProcessWithTokenW(hPrimaryToken,
                               0,
                               szApp,
                               szCmdLine,
                               0,
                               (LPVOID) NULL,
                               szCurrDir,
                               si,
                               pi))
  {
    wprintf(L"CreateProcessWithToken failed, error code: %u\n", GetLastError());
    goto cleanup;
  }

  bRetVal = TRUE;

cleanup:
  CloseHandle(hShellProcessToken);
  CloseHandle(hPrimaryToken);
  CloseHandle(hShellProcess);

  return bRetVal;
}


BOOL IsElevatedToken(HANDLE hProcessToken)
{
  DWORD elevationType  = 0;
  DWORD dwReturnLength = 0;

  if (!GetTokenInformation(hProcessToken,
                           TokenElevationType,
                           &amp;elevationType,
                           sizeof(elevationType),
                           &amp;dwReturnLength))
  {
    wprintf(L"GetTokenInformation failed, error code: %u", GetLastError());
    return FALSE;
  }
  else
  {
    switch (elevationType)
    {
      case TokenElevationTypeDefault:
        return FALSE;

      case TokenElevationTypeLimited:
        return FALSE;

      case TokenElevationTypeFull:
        return TRUE;

      default:
        return FALSE;
    }
  }
}


BOOL SetPrivilege(HANDLE hProcessToken, LPCWSTR lpszPrivilege, BOOL bEnablePrivilege)
{
  TOKEN_PRIVILEGES tp   = {0};
  LUID             luid = {0};

  if (!LookupPrivilegeValue((LPCWSTR) NULL,
                            lpszPrivilege,
                            &amp;luid))
  {
    wprintf(L"LookupPrivilegeValue, failed, error code: %u\n", GetLastError() );
    return FALSE;
  }

  tp.PrivilegeCount           = 1;
  tp.Privileges[0].Luid       = luid;
  tp.Privileges[0].Attributes = (bEnablePrivilege ? SE_PRIVILEGE_ENABLED : 0);

  if (!AdjustTokenPrivileges(hProcessToken,
                             FALSE,
                             &amp;tp,
                             0,
                             (PTOKEN_PRIVILEGES) NULL,
                             (PDWORD) NULL))
  {
    wprintf(L"AdjustTokenPrivileges failed, error code: %u\n", GetLastError() );
    return FALSE;
  }

  if (GetLastError() != ERROR_SUCCESS)
  {
    wprintf(L"AdjustTokenPrivileges failed to set the specified privilege.\n");
    return FALSE;
  }

  return TRUE;
}


LPWSTR GetFullPath(LPCWSTR szFilePath)
{
  LPWSTR szPath    = (LPWSTR) szFilePath;
  BOOL   bFreePath = FALSE;
  LPWSTR szBuf     = NULL;
  DWORD  dwBufLen  = 0;
  DWORD  nCCh      = 0;

  // Expand environment variables
  do
  {
    szBuf = (LPWSTR) realloc(szBuf, dwBufLen * sizeof(*szBuf));
    nCCh  = ExpandEnvironmentStrings(szPath,
                                     szBuf,
                                     dwBufLen);

    if (nCCh == 0)        break;
    if (nCCh == dwBufLen) break;

    dwBufLen = nCCh;
  } while (TRUE);

  if (nCCh &gt; 0)
  {
    szPath    = szBuf;
    bFreePath = TRUE;
  }

  // Search file name in PATH and current directory
  szBuf    = NULL;
  dwBufLen = 0;

  do
  {
    szBuf = (LPWSTR) realloc(szBuf, dwBufLen * sizeof(*szBuf));
    nCCh  = SearchPath((LPCWSTR) NULL,
                       szPath,
                       (LPCWSTR) NULL,
                       dwBufLen,
                       szBuf,
                       NULL);

    if (nCCh == 0)       break;
    if (nCCh &lt; dwBufLen) break;

    dwBufLen = nCCh;
  } while (TRUE);

  if (bFreePath)
    free(szPath);

  if (nCCh &gt; 0)
    return szBuf;
  else
    return NULL;
}
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/37049</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37049</guid><dc:creator><![CDATA[dinkumoil]]></dc:creator><pubDate>Sat, 01 Dec 2018 09:20:15 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Sat, 01 Dec 2018 05:01:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a></p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a> said:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dinkumoil" aria-label="Profile: dinkumoil">@<bdi>dinkumoil</bdi></a> said:</p>
<blockquote>
<p dir="auto">You have to provide the fully qualified path to <em>Calc.exe</em>/<em>Notepad++.exe</em>.</p>
</blockquote>
<p dir="auto">Yes I did. The following code doesn’t work neither:</p>
<pre><code>case IDM_FILE_NEW:
{
	//fileNew();
	::ShellExecuteA(NULL, "open", "explorer.exe", "C:\\sources\\notepad-plus-plus\\PowerEditor\\bin\\notepad++.exe -multiInst", "C:\\sources\\notepad-plus-plus\\PowerEditor\\bin\\", SW_SHOW);
}
break;
</code></pre>
</blockquote>
<p dir="auto">As you know <code>ShellExecute</code> parameters,<br />
Command/operation =&gt; “open”<br />
Command Location/File =&gt; “explorer.exe”<br />
Command Parameters =&gt; “C:\sources\notepad-plus-plus\PowerEditor\bin\notepad++.exe -multiInst”</p>
<p dir="auto">So here problem is command parameter which includes another command parameter. Try without “-multiInst”. It should work.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37047</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37047</guid><dc:creator><![CDATA[SinghRajenM]]></dc:creator><pubDate>Sat, 01 Dec 2018 05:01:12 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Sat, 01 Dec 2018 01:35:21 GMT]]></title><description><![CDATA[<p dir="auto">Hmm…<br />
The following code works :<br />
<code>ShellExecute(nullptr, L"open", L"explorer.exe", L"c:\\windows\\system32\\calc.exe", nullptr, SW_SHOW);</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/37045</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37045</guid><dc:creator><![CDATA[donho]]></dc:creator><pubDate>Sat, 01 Dec 2018 01:35:21 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Sat, 01 Dec 2018 01:30:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dinkumoil" aria-label="Profile: dinkumoil">@<bdi>dinkumoil</bdi></a> said:</p>
<blockquote>
<p dir="auto">You have to provide the fully qualified path to <em>Calc.exe</em>/<em>Notepad++.exe</em>.</p>
</blockquote>
<p dir="auto">Yes I did. The following code doesn’t work neither:</p>
<pre><code>case IDM_FILE_NEW:
{
	//fileNew();
	::ShellExecuteA(NULL, "open", "explorer.exe", "C:\\sources\\notepad-plus-plus\\PowerEditor\\bin\\notepad++.exe -multiInst", "C:\\sources\\notepad-plus-plus\\PowerEditor\\bin\\", SW_SHOW);
}
break;
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/37044</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37044</guid><dc:creator><![CDATA[donho]]></dc:creator><pubDate>Sat, 01 Dec 2018 01:30:04 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 20:56:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a></p>
<p dir="auto">You have to provide the fully qualified path to <em>Calc.exe</em>/<em>Notepad++.exe</em>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37034</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37034</guid><dc:creator><![CDATA[dinkumoil]]></dc:creator><pubDate>Fri, 30 Nov 2018 20:56:17 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 18:03:47 GMT]]></title><description><![CDATA[<p dir="auto">but i don’t know that code<br />
dism++ heve a method<br />
toolkit &gt; god mode<br />
run program without right checking</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37023</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37023</guid><dc:creator><![CDATA[rinku singh]]></dc:creator><pubDate>Fri, 30 Nov 2018 18:03:47 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 17:43:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/singhrajenm" aria-label="Profile: SinghRajenM">@<bdi>SinghRajenM</bdi></a><br />
It seems your method doesn’t work only for me.<br />
I test it in notepad++ with NO elevation, the following code launch calc well:</p>
<pre><code>		case IDM_FILE_NEW:
		{
			//fileNew();
			ShellExecute(nullptr, L"open", L"calc.exe", nullptr, nullptr, SW_SHOW);
	
		}
		break;
</code></pre>
<p dir="auto">However, the following code launch only explorer:</p>
<pre><code>		case IDM_FILE_NEW:
		{
			//fileNew();
			ShellExecute(nullptr, L"open", L"explorer.exe", L"calc.exe", nullptr, SW_SHOW);
	
		}
		break;
</code></pre>
<p dir="auto">What am I missing?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37021</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37021</guid><dc:creator><![CDATA[donho]]></dc:creator><pubDate>Fri, 30 Nov 2018 17:43:14 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 16:33:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/meta-chuh" aria-label="Profile: Meta-Chuh">@<bdi>Meta-Chuh</bdi></a> Again it depends upon how explorer.exe is executed. In most of the cases explorer is not elevated unless user explicitly do so.</p>
<p dir="auto">So if explorer is also elevated, then new exe also will be elevated yet. But it is expected in this case, because both will be at same integrity level which allows drag n drop.</p>
<p dir="auto"><a href="https://paste.pics/e25eda50315a622bfda372343fd9b722" rel="nofollow ugc">https://paste.pics/e25eda50315a622bfda372343fd9b722</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/37017</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37017</guid><dc:creator><![CDATA[SinghRajenM]]></dc:creator><pubDate>Fri, 30 Nov 2018 16:33:42 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 16:21:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/singhrajenm" aria-label="Profile: SinghRajenM">@<bdi>SinghRajenM</bdi></a></p>
<p dir="auto">thx, very cool and easy just to execute via explorer.exe, iv’e just tried it.</p>
<p dir="auto">i didn’t know that explorer.exe does not pass the elevation level to a spawn.</p>
<p dir="auto">so simple and perfect 👍</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37016</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37016</guid><dc:creator><![CDATA[Meta Chuh]]></dc:creator><pubDate>Fri, 30 Nov 2018 16:21:31 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 15:21:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a> said:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/singhrajenm" aria-label="Profile: SinghRajenM">@<bdi>SinghRajenM</bdi></a> said:</p>
<blockquote>
<p dir="auto">Also below can be used as simplest solution -</p>
<p dir="auto"><code>ShellExecute(nullptr, L"open", L"explorer.exe", L"C:\\Program Files\\Notepad++\\Notepad++.exe", nullptr, NULL);</code></p>
</blockquote>
<p dir="auto">Thank you for the info.<br />
I do remember the solution you provide in NSIS and did try the line above - only explorer launched.</p>
</blockquote>
<p dir="auto">Interesting. It is working fine to me.</p>
<p dir="auto">[Edit]:<br />
<a class="plugin-mentions-user plugin-mentions-a" href="/user/dinkumoil" aria-label="Profile: dinkumoil">@<bdi>dinkumoil</bdi></a>, nice catch. I’m using <code>SW_SHOW</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/37012</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37012</guid><dc:creator><![CDATA[SinghRajenM]]></dc:creator><pubDate>Fri, 30 Nov 2018 15:21:00 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 15:09:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a></p>
<p dir="auto">The last parameter has to be 1 = <em>SW_SHOWNORMAL</em></p>
]]></description><link>https://community.notepad-plus-plus.org/post/37011</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37011</guid><dc:creator><![CDATA[dinkumoil]]></dc:creator><pubDate>Fri, 30 Nov 2018 15:09:21 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 15:05:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/singhrajenm" aria-label="Profile: SinghRajenM">@<bdi>SinghRajenM</bdi></a> said:</p>
<blockquote>
<p dir="auto">Also below can be used as simplest solution -</p>
<p dir="auto"><code>ShellExecute(nullptr, L"open", L"explorer.exe", L"C:\\Program Files\\Notepad++\\Notepad++.exe", nullptr, NULL);</code></p>
</blockquote>
<p dir="auto">Thank you for the info.<br />
I do remember the solution you provide in NSIS and did try the line above - only explorer launched.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37009</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37009</guid><dc:creator><![CDATA[donho]]></dc:creator><pubDate>Fri, 30 Nov 2018 15:05:25 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 14:09:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a></p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a> said:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dinkumoil" aria-label="Profile: dinkumoil">@<bdi>dinkumoil</bdi></a><br />
Indeed.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/meta-chuh" aria-label="Profile: Meta-Chuh">@<bdi>Meta-Chuh</bdi></a> said:</p>
<blockquote>
<p dir="auto">possible solution:<br />
execute runas /trustlevel:0x20000 “C:\Program Files (x86)\Notepad++\notepad++.exe”</p>
</blockquote>
<p dir="auto">Just tried this method and seems Admin mode is OFF.<br />
However, drag &amp; drop a file into edit zone (which is the original motivation to run Notepad++ under user level) is forbidden just like Admin mode is ON.</p>
<p dir="auto">I will continue to search the alternative way.</p>
</blockquote>
<p dir="auto">Considering this scenario in mind, npp installer launches npp instance with same integrity level as explorer. Same is applicable here and drag n drop works fine using below method.  So I feel, this should suit your requirement.</p>
<p dir="auto"><code>ShellExecute(nullptr, L"open", L"explorer.exe", L"C:\\Program Files\\Notepad++\\Notepad++.exe", nullptr, NULL);</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/37004</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37004</guid><dc:creator><![CDATA[SinghRajenM]]></dc:creator><pubDate>Fri, 30 Nov 2018 14:09:33 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 14:00:16 GMT]]></title><description><![CDATA[<p dir="auto">Also below can be used as simplest solution -</p>
<p dir="auto"><code>ShellExecute(nullptr, L"open", L"explorer.exe", L"C:\\Program Files\\Notepad++\\Notepad++.exe", nullptr, NULL);</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/37003</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37003</guid><dc:creator><![CDATA[SinghRajenM]]></dc:creator><pubDate>Fri, 30 Nov 2018 14:00:16 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 13:27:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a><br />
Have looks at <a href="https://blogs.msdn.microsoft.com/oldnewthing/20131118-00/?p=2643" rel="nofollow ugc">article by Raymond Chen</a>.</p>
<p dir="auto">We already have a solution in place, but unfortunately that solution is in nsis. <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/c919dc6270534775e7f6a9a65db150d144e2aa20/PowerEditor/installer/nsisInclude/tools.nsh#L37" rel="nofollow ugc">Look here</a>. The idea is: Run a exe in explorer context.</p>
<p dir="auto">MS link: <a href="https://msdn.microsoft.com/library/dd940355" rel="nofollow ugc">https://msdn.microsoft.com/library/dd940355</a><br />
MS sample: <a href="https://github.com/pauldotknopf/WindowsSDK7-Samples/tree/master/winui/shell/appplatform/ExecInExplorer" rel="nofollow ugc">https://github.com/pauldotknopf/WindowsSDK7-Samples/tree/master/winui/shell/appplatform/ExecInExplorer</a></p>
<p dir="auto">Hope this will help you.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/37001</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/37001</guid><dc:creator><![CDATA[SinghRajenM]]></dc:creator><pubDate>Fri, 30 Nov 2018 13:27:08 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 10:43:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dinkumoil" aria-label="Profile: dinkumoil">@<bdi>dinkumoil</bdi></a></p>
<p dir="auto">this is just to get things going right now.<br />
it’s to quickly test if using the task scheduler works 100% for all cases.</p>
<p dir="auto">if it does, we can create an <a href="https://docs.microsoft.com/en-us/windows/desktop/taskschd/time-trigger-example--c---" rel="nofollow ugc">ITaskService</a> object unsing eg taskschd.h instead of a command line.</p>
<p dir="auto">if you have another working solution that is testable right now, don’t complain, try it, share it</p>
]]></description><link>https://community.notepad-plus-plus.org/post/36997</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/36997</guid><dc:creator><![CDATA[Meta Chuh]]></dc:creator><pubDate>Fri, 30 Nov 2018 10:43:51 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 09:47:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/meta-chuh" aria-label="Profile: Meta-Chuh">@<bdi>Meta-Chuh</bdi></a></p>
<p dir="auto">Yes, I remember. That was the way I suppressed UAC dialogs e.g. when starting elevated console windows around 10 years ago when I switched to Windows 7. It was the “I’m the admin, why should I been asked for approving admin tasks?”-attitude.</p>
<p dir="auto">But to use that from within an EXE -  hmm, seems crude to me…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/36996</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/36996</guid><dc:creator><![CDATA[dinkumoil]]></dc:creator><pubDate>Fri, 30 Nov 2018 09:47:23 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 09:32:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a></p>
<p dir="auto">please try this from an elevated cmd or gup exec line:</p>
<p dir="auto"><code>schtasks /create /tn "Notepad++ Update Reload" /tr "C:\Program Files\Notepad++\notepad++.exe" /sc once /st 23:59 /f &amp;&amp; schtasks /run /tn "Notepad++ Update Reload" &amp;&amp; schtasks /delete /TN "Notepad++ Update Reload" /f</code></p>
<p dir="auto">i remembered i had the same problem ages ago and solved it using the scheduled tasks<br />
this will create run once and delete one that uses the current user regardless of the elevation level of the parent task</p>
<p dir="auto">i’ve just tried it and drag and drop works, also <a class="plugin-mentions-user plugin-mentions-a" href="/user/dinkumoil" aria-label="Profile: dinkumoil">@<bdi>dinkumoil</bdi></a> the uac in the task manager should be correct</p>
]]></description><link>https://community.notepad-plus-plus.org/post/36994</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/36994</guid><dc:creator><![CDATA[Meta Chuh]]></dc:creator><pubDate>Fri, 30 Nov 2018 09:32:59 GMT</pubDate></item><item><title><![CDATA[Reply to Launch a No Elevated Process from an Elevated Process in an easy way (Win32 API) on Fri, 30 Nov 2018 09:15:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/donho" aria-label="Profile: donho">@<bdi>donho</bdi></a> said:</p>
<blockquote>
<p dir="auto">It’s full of hack, but I guess I have no choice :(</p>
</blockquote>
<p dir="auto">Well, I would call it “skillful use of officially documented features”. In contrast, the methods suggested in the MSDN blog entries I’ve posted a link to would have been real <strong>dirty</strong> hacks.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/36993</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/36993</guid><dc:creator><![CDATA[dinkumoil]]></dc:creator><pubDate>Fri, 30 Nov 2018 09:15:44 GMT</pubDate></item></channel></rss>