My first batch script

Background

I was assigned to a project in a highly secure air-gapped environment. My working laptop is issued by our client and it changes everytime. We have been using VMware vSphere to access all the servers.

All was good until our client started to block server access via vSphere. So now we can only access the server via RDP.

Problem

It require more steps to access those servers now.

  1. Open up an excel file which contains a list of the servers IP
  2. Open up a note file which contains the credential
  3. Launch Remote Desktop Connection app
  4. Copy and paste server IP
  5. Copy and paste username
  6. Copy and paste password
  7. Click connect in Remote Desktop Connection

Initial Idea

My inital idea was to create a PowerShell script that can store the list of servers in a dictionary (or hash table). And it will display a list of servers and ask for your input to access which server.

But I’m not satisfied with this additional step, I want to access the server much faster - like just double click a file and I’m in.

Solution

Using batch script I can predefined the server IP and credential. The only issue is that I have to create a batch file for each server but it achieve my “double click” requirement. The time creating those batch files versus time saving for our team is definitely worth it.

Here’s what the batch script does using cmdkey command:

  1. Store server IP and credential
  2. Launch Remote Desktop Connection and connect to the server
  3. Delete server IP and credential

It is important to remove the server IP and credential after used because I do not want to store it in the laptop.

With this solution, I organized primary and seconday servers in folders and name the batch file by Application Name and Hostname like this: BITBUCKET HOSTNAME.bat

Problem with my solution

The thing is, in a highly secure environment, password changes frequently. So what this mean is I have to edit all the batch files with new password when that happens. Of course I knew there must be a better way, and sure it is. PowerShell script is here to save the day! First you need to define the path to the batch files, and using the find and replace function to change the password. Pretty neat huh?

Reality

So at home I have all the solutions tested and ready. Excitingly in data centre, I opened up my work laptop happily typing in the codes line by line and then realized the batch script did not work. I still have to type in username and password!

Long story short, our client has disabled the ability to retrive saved credentials. Well, that’s life. At least I’ve tried. And maybe this simple script can work for you or my future project.


You can find the scripts in my GitHub Repository.

My Thoughts

2026 · 10 Claude cloud session 2026 · 10 Building a haze app 2026 · 10 New Apple TV with Siri AI? No thanks 2026 · 10 It's just business 2026 · 10 A post from Claude app 2026 · 09 Happy birthday to me 2026 · 07 “Free iPad” after 201 days 2026 · 07 Bus filtering feature for my app 2026 · 07 Replacing a mixer tap 2026 · 07 Assume all medias are AI-generated
Show more 2026 · 05 Redesign ZheBus 2.0 with Claude Design 2026 · 05 Apple Fitness+ 2026 · 05 Customizing my Obsidian 2026 · 04 Using AI to build utility app 2026 · 04 大山 2026 · 04 Exploring Obsidian again 2026 · 04 “I have plenty of time.” 2026 · 04 Vacuum storage bag 2026 · 04 AI for Grab 2026 · 04 Jensen Huang on Lex Fridman podcast 2026 · 04 The Shangri-La view 2026 · 04 My first automated posting workflow 2026 · 04 Migrate from Kirby to Jekyll 2025 · 08 Switching to Notion 2025 · 08 ZheBus 1.2 is live 2025 · 08 Live Activity submitted for review 2025 · 07 Damn it, Live Activity! 2025 · 06 Liquid Glass app icon 2025 · 06 Improving ads layout 2025 · 06 ZheBus is LIVE! 2025 · 06 My app got approved! 2025 · 05 How ZheBus got its name 2025 · 05 Paid app or show ads? 2025 · 04 Designing the bus icon 2025 · 04 Rebuild from scratch 2025 · 04 Competitive analysis 2025 · 03 Momentum gone 2025 · 03 Completing… 2025 · 02 The first screenshot 2025 · 02 My pain point 2025 · 02 Cursor 2025 · 02 Vibe coding 2025 · 01 Right or easy way 2024 · 10 Optimizing hospitalization experience 2024 · 10 First post on my new MBA 2024 · 09 Impulse buy 2024 · 09 My birthday wish 2024 · 08 I deleted singaporeofficespaces.com 2024 · 03 Bad month 2024 · 03 96995110 Dishonest Carousell seller 2024 · 03 Life after quitting social media 2024 · 02 Social media automation 2024 · 02 I don't send birthday wishes 2024 · 02 Confrontation 2024 · 02 Leecher 2024 · 02 Free web hosting 2024 · 02 曾宝仪 2024 · 01 SiteGround replacement 2024 · 01 2024 Resolutions 2023 · 12 Huat Ah in funeral 2023 · 09 Monster Hunter Now 2023 · 08 Be the BMW 2023 · 05 Why the rush? 2023 · 04 Whatever 2023 · 04 Overnight Oats 2023 · 01 2023 Resolutions 2022 · 10 Learning Machine Learning 2022 · 09 AWS Certified Cloud Practitioner 2022 · 08 IIS Hardening 2022 · 08 Job alert script 2022 · 07 My first batch script 2022 · 06 16:8 Diet 6 months later 2022 · 05 Keep trying 2022 · 03 SGUnited Mid-Career Pathways Programme 2022 · 03 I sold my FBRX shares 2022 · 03 Python course completed 2022 · 03 Pixel perfect 2022 · 03 Personality Test 2022 · 03 Breathless 2022 · 02 I got Covid-19 2022 · 02 My ideal automation project 2022 · 02 Found a better Python course 2022 · 02 Crash Course on Python 2022 · 02 Options trading final update 2022 · 01 Google IT Automation Professional Certificate 2022 · 01 2022 Nasdaq iCal Calendar 2022 · 01 I have no luck 2022 · 01 Options trading update #5 2022 · 01 2022 Resolutions 2021 · 12 Quality time 2021 · 12 Options trading update #4 2021 · 11 16:8 Diet 2021 · 11 Options trading update #3 2021 · 10 Distraction-free 2021 · 10 Life Point System 2021 · 10 Options trading update #2 2021 · 09 余世维 2021 · 09 Turning blue 2021 · 09 Semi-retire from social media 2021 · 09 Not so contactable 2021 · 09 Singapore bans Binance 2021 · 09 Teaching my son about money 2021 · 09 Worse trading nightmare 2021 · 09 40 2021 · 09 I'm a Transonic Achiever, so what? 2021 · 09 Options trading update #1 2021 · 08 Intensive learning 2021 · 08 NDP 2021 Theme Song – The Road Ahead 2021 · 07 Options trading 2021 · 07 Squared Online Digital Marketing Course 2021 · 07 Don’t bro me 2021 · 07 Discord is WhatsApp’s future 2021 · 07 Interactive Brokers 2021 · 07 Smoking cabin 2021 · 06 At my own pace 2021 · 06 A boss that cares 2021 · 06 Reduce social media consumption 2021 · 06 $90 for an app 2021 · 06 Developing an app from start to finish 2021 · 06 Blog 3.0 2021 · 06 ikigai 2021 · 05 Unwind 2021 · 05 Handful of friends 2021 · 05 Sold my car 2021 · 05 Tiger Brokers 2021 · 04 My perfectionism 2021 · 02 Keeping ahead by staying behind 2021 · 02 Birthday wishes on Facebook 2021 · 02 Selling Clubhouse invitation 2021 · 02 Hello world 2.0