Just Add Comments, Please.

Quick Notes on organizing your scripts for future use.

Mason C.B.
2 min readJul 20, 2022

--

Unrelated Generic Code Snippet / Photo by Shahadat Rahman on Unsplash

Preface

To get this blog started, I really just wanted to start writing... about ANYTHING. So I figured starting with something that comes up at work quite often is as good a place as any.

Many times people find themselves in a position where they are going back over work that was created by someone who no longer is there. In this case, I’m talking about myself and almost any SCCM package I have come across.

I was given an update to a package and found that most of the old files had no organization. What irks me about this is how simple it is to be descriptive.

Bad Formatting

For example, using a .bat that I have launch some daily apps:

@ECHO OFF
START “notepad.exe” "C:\Users\User\Desktop\notes.txt"
START “slack.exe” “C:\Users\User\AppData\Local\slack\slack.exe”
START “Spotify.exe” “C:\Users\User\AppData\Roaming\Spotify\Spotify.exe”
START “CiscoJabber.exe” “C:\Program Files (x86)\Cisco Systems\Cisco Jabber\CiscoJabber.exe”
START chrome.exe “https://mail.google.com/mail/u/0/#inbox" “https://service-now.com"
START “C:\Program Files (x86)\Google\Chrome\Application\chrome_proxy.exe” “C:\Users\User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Google Calendar.lnk”

It isn’t IMPOSSIBLE to read, but it’s certainly not clear. Imagine expanding on this with more programs (which I have) or simply writing anything longer.

I have come across old files that point to license servers, create paths, delete directories, call other programs (at this point using a batch files might have been a bad idea versus PowerShell, VBScript, etc.) but when coming from someone else’s work, it’s hard to find the time to completely rewrite something.

Good Formatting

A better solution is SO simple, just use comments and spaces. Better yet, add separate documentation that breaks things down when needed. Wild, right?

@ECHO OFF::Daily Programs (Notepad, Slack, Spotify, etc.)
START “notepad.exe” "C:\Users\User\Desktop\notes.txt"
START “slack.exe” “C:\Users\User\AppData\Local\slack\slack.exe”
START “Spotify.exe” “C:\Users\User\AppData\Roaming\Spotify\Spotify.exe”
::Work Tools (Cisco Jabber, etc.)
START “CiscoJabber.exe” “C:\Program Files (x86)\Cisco Systems\Cisco Jabber\CiscoJabber.exe”
::Chrome Tabs (Google Mail, ServiceNow, etc.)
START chrome.exe “https://mail.google.com/mail/u/0/#inbox" “https://service-now.com"
::Google Standalone Shortcuts (GCal in it's own Window)
START “C:\Program Files (x86)\Google\Chrome\Application\chrome_proxy.exe” “C:\Users\User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Google Calendar.lnk”

It is so easy to do. Think of your coworkers (the ones you like, that is) the next time you write anything that may get reused.

Closing

I know this isn’t revolutionary and I could (maybe I will) write an entire blog on proper documentation, ways to improve upon it, and better yet organize it… but putting my 2 cents on the internet makes me feel just a little bit better.

Besides, maybe the old SysAdmin who left me a 4 page batch file (yes 4 pages, it was a word document for some reason) with no comments might learn a thing or two from this post…

Mason C.B.

--

--

Mason C.B.

DevSecOps / Creative Hobbyist. Just trying to be all that I can.