Jeremy Stein
Jeremy Stein

Reputation: 19661

Scheduled task to open URL

At a certain time each day, I'd like my browser to pop open a tab to a certain URL.

My goals:

  1. be able to set the URL from the scheduled task
  2. use the default browser (rather than hard-coding it)

I can't seem to accomplish both of these goals at once. I'll post my partial solutions as answers, but I'm hoping someone will have something better.

Upvotes: 4

Views: 10046

Answers (5)

dmb
dmb

Reputation: 603

Note that this command will open the default browser (or a new tab therein) to the given url:

cmd /c start http://example.com

To create a scheduled task without the command window popping up:

Create OpenUrl.vbs:

CreateObject("Wscript.Shell").Run "cmd /c start " & Wscript.Arguments.Item(0), 0, False

Then call it from a scheduled task with this command:

wscript.exe "C:\Path\To\Script\OpenUrl.vbs" http://example.com

Upvotes: 8

PatBoule
PatBoule

Reputation:

One additional thing to note for the FF solution - if your URL has ampersands in it - you may need to escape those in Scheduled tasks using the caret ^& character.

Oops - this is wrong. The ^ was needed to escape the Ampersand when testing the link in a CMD window - but is okay in the actual Scheduled Task.

Upvotes: 0

FKDev
FKDev

Reputation: 2286

Well, you could just create the url file from your script :

Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile= fso.CreateTextFile("c:\example.url", True)
MyFile.WriteLine("[InternetShortcut]")
MyFile.WriteLine("URL=http://stackoverflow.com/questions/2655253/scheduled-task-to-open-url")
MyFile.Close

Upvotes: 1

Jeremy Stein
Jeremy Stein

Reputation: 19661

This solution is hard-coded to Firefox:

Create the scheduled task with this URL:

"C:\Program Files\Mozilla Firefox\firefox.exe" -new-tab http://example.com

Upvotes: 2

Jeremy Stein
Jeremy Stein

Reputation: 19661

This solution doesn't allow me to set the URL from the scheduled task:

Create a .url file pointing to the URL I want.

Create a .vbs script that opens the URL:

CreateObject("Wscript.Shell").Run """example.url""", 0, False

Create the scheduled task to run the .vbs script.

Upvotes: 0

Related Questions