3

So I have a batch file that copies files from one folder to a bunch of different folders.

The purpose of this batch file is to be like a simple installer(Without registry edits) to make it easier for others to use a set of files I am distributing. Because this is being widely distributed, it will need to work on windows operatings systems from XP on. The files need to be moved to the program files of a program (This works), their documents folder(Also works), and the program folder in the all users start menu(Does not work).

So far I have been unsuccessful with xcopy and robocopy as they both tell me "access denied". Also running the batch file with "Run as administrator". If you can think of a more effective way to do what I'm trying to do besides a batch file I am open to ideas.

xcopy /q /y ".\add_ui.bat" "%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\My Program\Add.bat"

I'm sure there's some simple trick that I'm missing.

Thanks in advance!

3
  • 2
    You're probably using the wrong path. Show your code, and tell us which version of Windows you're targeting. Jan 9, 2014 at 21:01
  • Made the edit to show. Thanks for the response! Jan 10, 2014 at 12:49
  • There's nothing obviously wrong with that command (on Windows Vista or later) provided it is run from a run-as-administrator console window and provided the "My Program" folder already exists. The path for Windows XP is different, of course. Jan 12, 2014 at 19:36

2 Answers 2

2

You must have local admin rights to write to that folder and your batch file will need to be ran with elevated permissions (Run As Adminstrator).

5
  • Is there anyway for me to get around that? Jan 10, 2014 at 13:54
  • No, there is no way around it. Do you have to put the files in the All Users Start Menu? Could you instead put them in the current user's Start Menu?
    – aphoria
    Jan 10, 2014 at 14:30
  • Unfortunately not, it's sort of an add on to an existing program which uses the all users start menu. It's for low technical ability uses so I would end up confusing them with the current users start menu. I'm not totally attached to .bat files, do you suggest anything that might be easier? Thanks so much for your responses so far! Jan 10, 2014 at 15:53
  • If "Run as administrator" succeeds, then you have local admin rights. Jan 12, 2014 at 19:32
  • @HarryJohnston You're correct. My original answer wasn't clear on that.
    – aphoria
    Jan 12, 2014 at 19:44
0

Only one problem here. With running batch file as administrator, the CMD moves to \Winodws\System32 so copying make it impossible because the files to be copied are no longer in the root directory (i.e. \Windows\system32) they are back where the batch file was.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.