A batch file that copies another into Start Up folder?

36,942

Solution 1

You can also try this:

cd %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup

It works in Windows 10. The %appdata% variable gives you your required username by default

Solution 2

Open a new command prompt window by executing cmd.exe or using the shortcut in Accessories in Windows start menu. Enter set and look on the list of environment variables predefined by Windows. You are mostly interested in USERPROFILE.

The following command can be used to copy a batch file with name AaRM.bat from a folder available for all users like the all users desktop folder to startup folder of the currently logged in user.

copy "%ALLUSERSPROFILE%\Desktop\AaRM.bat" "%USERPROFILE%\Start Menu\Programs\Startup"

The double quotes are important as the name of the batch file with path and the path to the startup folder both contain spaces.

Copying the batch file from your desktop folder to the startup folder of the other user is most likely not possible as the other user might have no permission to access anything in your user profile directory and below.

You can copy the batch file to distribute also to a different folder accessible for all users like "%ProgramFiles%" or %SystemRoot% as the batch file in all users desktop folder is visible for all user accounts on desktop.

Best would be to put the batch file into Windows directory (%SystemRoot% or %windir%) and create / copy a shortcut file (*.lnk) in / to startup folder of the other user accounts. The Windows start menu folders should contain only *.lnk files and not batch files and applications.

And last it would be also possible to create a shortcut in "%ALLUSERSPROFILE%\Start Menu\Programs\Startup" to the batch file in %windir% to execute this batch file for any user who logs in on this computer. Your batch file could contain at top something like if "%USERNAME%"=="your account name" goto :EOF 1 or more times with various user account names to prevent doing anything for 1 or more specific users.

Solution 3

Stumped about nobody answering yet.. Why are we so lost?

echo %userprofile%

To know the name of current user

For copying Copy /y %~f0 "%USERPROFILE%\%AppData%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Alternative copy "path of file you want to copy" "path of the directory where you want it copied"

copy path of batch file path of startup folder

Solution 4

try the following command if u r using win 7. never tried on win 8 though.

cd C:\Users\%username%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

works perfectly for me.

Share:
36,942
Admin
Author by

Admin

Updated on January 13, 2021

Comments

  • Admin
    Admin over 3 years

    I am making a batch file that needs to copy another batch file into the Start Menu Start Up folder (the one used when a program launches on login/start up). Since the path uses the user's computer name eg. C:\Documents and Settings\User Name I need the batch file to get the user's correct name instead of the "User Name" or * (wildcard). Wildcards doesn't work as the batch file comes up with "the filename directory name or volume label syntax is incorrect".

    I hope this is clear enough.

  • Stephan
    Stephan almost 7 years
    please read the question again. This does not really help, as OP is looking for a path including %username%