Search code examples
batch-filefile-iostartupwindows-7-x64

Unable to copy file using batch to startup folder


I am trying to make a batch file that will copy two files from a USB to two different folders and I'm using this code

cd %~dp0 
mkdir c:\temp
xcopy /Y Firstfile.exe C:\temp

xcopy  /E /Y /V /I /S %cd%\secondFile.vbs "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\StartUp"

The first part works perfect, creates the folder and copy firstfile.exe

The problems start at the second part where I'm trying to copy secondFile.vbs to startup, I get no error but the file do not appear in startup folder.

I am using Windows7 -x64 enterprise


Solution

  • You don't need xcopy (and some of those switches are not needed) but it should work.

    Try copy instead and note the different path as c: may not be the drive where the users folder is stored.

    Make sure you check the startup folder location

    copy "secondFile.vbs" "%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\StartUp" >nul