Domanda

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

È stato utile?

Soluzione

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

Altri suggerimenti

If your batch file current path is the same of the secondFile.vbs, you don't need %cd%. But, if you want to use %cd% try to surround with quotes: %cd%\secondFile.vbs. I guess you don't need /E /V or /S arguments.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top