Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

Thank!

share|improve this question

migrated from stackoverflow.com 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.