title: %LOCALAPPDATA% usage in CreateProcess
body: <p>I am trying to code an executable that will call an exe file when run.</p>
  
  <p>The windows location of the file is:</p>
  
  <pre><code>"C:\\Users\\User1\\AppData\\Local\\Apptest\\Application\\apptest.exe"
  </code></pre>
  
  <p>Because it is located inside Local App Data folder for the user profile, it needs to be called with <code>%LOCALAPPDATA%</code>  short-cut because I will share the execurable with others.</p>
  
  <p>The below code calls above path via a short-cut:</p>
  
  <pre><code>"%LOCALAPPDATA%\\Apptest\\Application\\apptest.exe"
  </code></pre>
  
  <p>but it does not work.</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;windows.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;io.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;shellapi.h&gt;
  #include &lt;tchar.h&gt;
  #include &lt;time.h&gt;
  #include &lt;iostream&gt;
  
  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
  
      STARTUPINFO siStartupInfo;
      PROCESS_INFORMATION piProcessInfo;
      memset(&amp;siStartupInfo, 0, sizeof(siStartupInfo));
      memset(&amp;piProcessInfo, 0, sizeof(piProcessInfo));
      siStartupInfo.cb = sizeof(siStartupInfo);
  
  
      if (CreateProcess(_T("%LOCALAPPDATA%\\Apptest\\Application\\apptest.exe") ,NULL, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &amp;siStartupInfo, &amp;piProcessInfo)){
          WaitForSingleObject(piProcessInfo.hProcess, INFINITE);
          CloseHandle(piProcessInfo.hProcess);
          CloseHandle(piProcessInfo.hThread);
      }
      else {
          MessageBox(0, TEXT("Can not start program"), TEXT("AppTest"), MB_OK);
          exit(0);// Shutdown on fail
      }
  
      return 0;
  }
  </code></pre>
  
  <p>How is <code>%LOCALAPPDATA%</code> short-cut is used in <code>CreateProcess</code>?</p>