Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im trying to write a batch file that copy itself to startup folder, so the file will be executed each restart. Im using this command, but I keep getting "access denied":

@echo off
XCOPY txt.txt "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\StartMenu\Programs\Startup" /y /c /h /o /b

When I try to move the file manually, i need to click on a "Continue" button, so I guess I cannot access to the destination. How can i access to the folder and copy the file?


share|improve this question

migrated from Jun 19 '13 at 1:52

This question came from our site for professional and enthusiast programmers.

you should contact an administrator to get permission. – Endoro Jun 18 '13 at 23:29
I'm going to guess that the problem lies in the %username% var. If you change that to your username, does the file copy? Sounds like it could be an environmental variable issue. Which user is running the script? On start up, this would be a system account, correct? That account doesn't have a folder in C:\Users\.. etc. – skub Jun 19 '13 at 2:42
Try removing /o, which copies ownership. – Alex Jun 19 '13 at 4:48

You must log in to answer this question.