2022-05-06


Racket Startup Scripts on Windows

Hello everyone! Wanted to make simple little post here that you may find useful. Most of what I use on a daily basis at work is cloud based in an internal network. Usually I start my day of by loading a web browser, opening several tabs, an email client and a terminal. In the past I have automated this using a simple .bat file, but I really love Racket and wanted to something similar within Racket. As it turns out, it is quite simple to do this.

Doing this in a batch file is quite simple, all you really need is the START and TIMEOUT commands. Here is a simple example:

START https://www.google.com
TIMEOUT /t 5
START https://www.youtube.com
TIMEOUT /t 5
START thunderbird
:: and so on

To do the same thing on Racket, it is quite similar. Here is my startup script(with URL's changed here):

#lang racket/base
(require net/sendurl)
(require racket/system)
(require racket/gui/base)

; URL List
(define url-list '("https://www.youtube.com/user/TheCaptBubbles/playlists"
                        "https://calixcloud.calix.com/login"))

; List of Apps
(define app-list '("start wt"
                        "start thunderbird"))

; Open URLs in default browser
(for ([i url-list])
    (send-url i)
    (sleep/yield 2))

; Open Apps
(for ([i app-list])
    (system i)
    (sleep/yield 2))

To make this work you need to import:

Then all I did was create a list for URLs and a list for apps and loop through opening them.

And that is really it! All you need to do is either run this manually when you start your machine, or create a shortcut and make that executable and place it in your shell:startup folder. Placing the shrotcut there will run this script at startup. I personally just keep it as a shortcut on my dekstop and run it when I arrive to work. Hope you found this helpful!