Linux .bashrc equivalent on windows

In my current project I use Kubernetes & docker tools on Windows  10 . To interact with Kubernetes  and Docker environment typical we use kubectl & Docker command line tools , typing  these commands all day is not fun , so I was searching for solution to create some sort of shorter alias for these commands.

This is easy on Linux with ‘alias‘ command put it into  .bashrc , I was looking for similar solution on Windows . After googling around found that with .cmd file & some registry magic we can do the same.

Here are the steps .

        • Under HKCU\SOFTWARE\Microsoft\Command Processor added  value: AutoRun of type REG_EXPAND_SZ with value %USERPROFILE%\cmdrc.cmd. This is required to persist setting across reboots. reg
        • Created cmdrc.cmd in my userprofile directory.You can access the user profile with %USERPROFILE% environment variable.
        • Added following content in cmdrc.cmd file
          @echo off
          DOSKEY ls=dir
          DOSKEY cd=cd $1$Tdir
          DOSKEY clear=cls
          DOSKEY k8s=kubectl $*
          DOSKEY dk=docker $*


With this setting in place any new command instance will have shorter alias set in cmdrc.cmd

cmd

More informaton

Advertisements

Step by step guide install Windows 10 using boot to VHD feature

Windows 10 is coming this year, as technology enthusiast I always interested to tryout and explore features set and developer opportunities. In this blog post I will explain how to install and explore windows 10 safely on your computer without using virtual machine software or creating new partition in your hard drive.

Boot to VHD

Boot to VHD is feature in Windows 7 (higher) system , that allows to boot windows operating system from the VHD file ( virtual hard disk file ). Basically Windows 7 systems boot loader understands , how to boot from VHD file. I wrote blog post how to do it for Windows 7 (here). In this blog post I will show how to do it on Windows 8 .

First thing download windows 10 iso file from Microsoft site. You can download the iso file by be joining Microsoft Windows insider program.

Create VHD/VHDX file from the ISO.

  • Download the Convert-WindowsImage.ps1 PowerShell script from TechNet site that allows you to create VHD/VHDX file from ISO.Launch PowerShell command  prompt as administrator, execute command to enable execution of unsigned scripts ,

Set-ExecutionPolicy Bypass -Scope Process

  • Run downloaded script in interactive mode by executing .\Convert-WindowsImage.ps1 –ShowUI command . At the end of the execution it scripts creates vhdx file  in the working directory.

image

  • Mount the virtual hard disk image from working directory.

image

  • Once image is mounted  you should be able to see new drive in your explorer. In my case it is attached ‘G’ drive.

image

 

Update boot record.

  • Now run following command create new bootable entry. Replace G:\Windows with your location where vhdx image is mounted

bcdboot G:\windows

image

  • Verify that boot order is updated properly by running msconfig.exe. You should see new entry.

image

  • Restart computer , you should new boot option.

Uninstall Windows 10 (Removing boot entry).

If you want to remove boot entry you can follow the steps

  • Launch msconfig.exe from the admin command prompt  and select entry you want to delete and press delete, reboot.

image