How do I get a .bat file to run in Task Scheduler at PC Startup?

18,248

Solution 1

Simply point the Scheduler's task to the .bat file itself. That is - in the Actions tab have Start a program entry that leads straight to the .bat file - not cmd.exe with parameters.

Solution 2

I am using the "Startup" folder for bat files to be executed at the startup.

Copy your bat file in your "Startup" folder (for example C:\Users\*your username*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup).

Replace exit by pause at the end of the bat file (exit is not needed here anyway). This is for testing purposes. The command prompt will not close until you will press a key. It is good way to see if there were any errors during the executing the commands from the bat file.

Remove the pause command when you are happy with the result.

Share:
18,248

Related videos on Youtube

Radical924
Author by

Radical924

Updated on September 18, 2022

Comments

  • Radical924
    Radical924 over 1 year

    Alright so I have been reading through the various answers on Super User for this question and no one has seemed to actually post a way of running a .bat file in Task Scheduler at PC startup. I would like to do this...

    I tried having Task Scheduler start cmd.exe at PC startup with the arguments being the directory of the .bat file but it just does not work. Even if it says it does run the .bat the .bat's commands don't execute... How do I get it so it can run in Task Scheduler without this issue?

    • Radical924
      Radical924 over 10 years
      I am running deletion commands...
    • nixda
      nixda over 10 years
      Can we see your .bat file content, task trigger and task arguments?
    • Nikola Dimitrijevic
      Nikola Dimitrijevic over 10 years
      Have you selected "Run whether user is logged on or not" or "Run only when user is logged on" radio button? Do you actually need to do that via Task Scheduler? You can run your bat file at startup by pasting a shortcut to the .bat file into: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
    • Radical924
      Radical924 over 10 years
      Yeah I have... Here is the .bat file I have so far: pastebin.com/raw.php?i=WM9v4dS1 The files are not being deleted at startup as indicated in the lines f the .bat file...
    • Rik
      Rik over 10 years
      How do you know your bat-file ran? Perhaps cmd.exe just executed with an error (which you don't see because it runs invisible). Please provide the screenshots of your task in the taskmanager. You stated you gave cmd.exe the arguments being the directory of the .bat. That won't work. You'll also need to include the batfile-name. So we need to see some screenshots.
  • Radical924
    Radical924 over 10 years
    That won't work for some reason... Idk I am going to keep playing around with the user maybe that'll work...
  • gronostaj
    gronostaj over 10 years
    @Radical924 what do you mean by "won't work"?
  • Radical924
    Radical924 over 10 years
    If you read my comment above the bat file will run but its commands do not execute... I will post my .bat that I have so far above in the comments.
  • Radical924
    Radical924 over 10 years
    I ended up getting it working... I used the invisible.vbs script thing on here: superuser.com/questions/62525/run-a-completly-hidden-batch-f‌​ile and followed the post and it all works now... Thanks though... idk why it wasn't working before but your post did make me look more into it and I found that post...