title: Why does Jenkins use a different temp folder when launched from jar or from a service?
body: <p>I have been trying to launch a testing app from Jenkins . Initially I started Jenkins from the Jar file and things were working fine.</p>
  
  <p>This was the console output:</p>
  
  <pre><code>Started by user ABC
  Building in workspace C:\MyDir
  [xyz] $ cmd /c call C:\Users\usrname\AppData\Local\Temp\hudson2329759222967199349.bat
  ...
  </code></pre>
  
  <p>Now when I start Jenkins as a Windows service</p>
  
  <pre><code>Started by user ABC
  Building in workspace C:\MyDIr
  [xyz] $ cmd /c call C:\WINDOWS\TEMP\hudson4009309858990093371.bat
  C:\MyDir&gt;gauge specs 
  Failed to start gauge API: Plugin 'java' not installed on following locations : [C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\gauge\plugins]
  </code></pre>
  
  <p>Why does it run it from a different temp folder?
  I tried rectifying things by adding the AppData\Local\Temp path to jenkins.xml</p>
  
  <pre><code>&lt;executable&gt;java&lt;/executable&gt;
    &lt;arguments&gt;-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle
      "-Dhudson.model.DirectoryBrowserSupport.CSP=sandbox allow-scripts; default-src 'self' 'unsafe-inline' ; img-src 'self'; style-src 'self' 'unsafe-inline';"
      -Djava.io.tmpdir="C:/Users/username/AppData/Local/Temp" 
    -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"&lt;/arguments&gt;
  </code></pre>
  
  <p>If it helps: Jenkins is installed in C:\Users\username.jenkins
  The Jenkins page just refuses to load. 
  What should I do?</p>