How to get around the (Access is denied) to a folder that your java program is saving a file to?
<p>I was wondering if someone could help me find a good resource to help me fix this issue. I'm trying to create/save a batch file in the startups folder. Here's the general path: <code>C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\startup_PMA_popup_check.bat</code></p>

<p>I've read a lot of things saying that I should simply elevate the privileges of my java program.
I read that if I was to make my jar file a windows executable, then the rights of the program are automatically elevated to admin privileges.</p>

<p>What you're seeing below is my jar turned into an exe and run. The error I got was the same error as the one I got from running my jar. I no longer think that the problem is simply giving my program admin privilege.</p>

<p>I performed a test outside of my program by going to this path and attempting to move a file into the folder. Assuming I'd have no issue "since I am root already", I went ahead expecting to get no prompts. What I got was a popup saying that I needed to confirm that I was Admin &amp; to confirm that I wanted to put the batch file in the folder.</p>

<p>My question is how should I make my java program issue this prompt to the user or something so my program can continue &amp; not crash like shown below??:</p>

<blockquote>
  <p>Exception in thread "main" java.io.FileNotFoundException:
  C:\ProgramData\Microsoft\Windows\Start
  Menu\Programs\StartUp\startup_PMA_popup_check.bat (Access is denied)
          at java.io.FileOutputStream.open0(Native Method)
          at java.io.FileOutputStream.open(Unknown Source)
          at java.io.FileOutputStream.(Unknown Source)
          at java.io.FileOutputStream.(Unknown Source)
          at java.io.PrintWriter.(Unknown Source)
          at java.io.PrintWriter.(Unknown Source)
          at prioritymanagementassistant.Background.createBatchFile(Background.java:106)
          at prioritymanagementassistant.Main.main(Main.java:930)</p>
</blockquote>

<p>Thank You for your time,</p>