Start batch files at startup...

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Posts: 31
Joined: 23 Apr 2020 13:05

Start batch files at startup...

#1 Post by rasil » 21 Apr 2021 09:58


I want to create a batch file that when you run it, it puts itself in the startup folder or something like that. I searched on google and all the solutions require you to manually put them in the startup folder or make a regedit file. Is something like that going to be possible?

Posts: 21
Joined: 15 Sep 2019 05:33

Re: Start batch files at startup...

#2 Post by Maylow » 21 Apr 2021 11:04

Probably because by default access to "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\" is restricted for security reasons.

You can copy to the user startup folder %APPDATA%\Microsoft\Windows\Start Menu\Programs\StartUp\, no problem.

Code snippet of batch script that copies itself to user startup folder:

Code: Select all

copy "%~f0" "%APPDATA%\Microsoft\Windows\Start Menu\Programs\StartUp\%~nx0"

Posts: 92
Joined: 15 Apr 2014 17:59

Re: Start batch files at startup...

#3 Post by Hackoo » 24 Apr 2021 03:39

Hi :)
Just give a try for this batch file :

Code: Select all

@echo off
Title Create a shortcut on Startup Folder of my batch file using Powershell
::-----------------------Calling our Sub-Routine Create_Shortcut_Startup -------------------------------
Call :Create_Shortcut_Startup
::-------------------------------Begin Main Batch code here --------------------------------------------
echo Done and your main batch goes here !
echo i am a test 
::-------------------------------End Main Batch code here-----------------------------------------------
Powershell -C ^
"$s=(New-Object -COM WScript.Shell).CreateShortcut('"%AppData%\Microsoft\Windows\Start Menu\Programs\Startup\%~n0.lnk"'); ^
$s.TargetPath='"%~f0"'; ^
Exit /B

Post Reply