How to display ipconfig on Nano Server every time it boots


When you read through the “Getting Started with Nano Server” guide, you’ll come across SetupComplete.cmd and you’ll appreciate that you can display ipconfig on first boot.  But that’s really not enough.  I want to display ipconfig (and possibly other things) *every* single time Nano Server boots.  Here’s how to do it:

This blog post assumes that you’ve already built your Nano Server image and added your favorite roles, but have not yet booted it.  

Create 2 command files with the following content:

 

SetupComplete.cmd

ipconfig

schtasks /create /tn "Start" /tr c:\windows\system32\Startup.cmd /sc onstart /ru "System"

 

Startup.cmd

ping 1.1.1.1 –n 7

ipconfig

 

Quick explanation:

SetupComplete.cmd executes only on first boot, so what we’re doing is scheduling a task which executes on start:

  • /tn: Task name

  • /tr: Task run – the task to run

  • /sc: schedule – in our example, OnStart, i.e. on every boot

  • /ru: Run as – in our case, as “System” – very important!

Startup.cmd will be run on every boot. I had to introduce an artificial delay (ping), because apparently, Nano Server starts too fast J - go ahead and experiment with this delay, and see if you need it in your scenario.

Of course, you can replace ipconfig with any command you want, but remember that anything that scrolls off the screen cannot be retrieved. J

 

Mount the image:

dism /Mount-Image /ImageFile:.\nanoServer.vhd /Index:1 /MountDir:.\mountdir

 

Copy SetupComplete.cmd to the image:

md .\mountdir\Windows\Setup

md .\mountdir\Windows\Setup\Scripts

copy .\SetupComplete.cmd .\mountdir\Windows\Setup\Scripts

 

Copy Startup.cmd to the image:

copy .\Startup.cmd .\mountdir\Windows\System32

 

Unmount the image:

dism /Unmount-Image /MountDir:.\MountDir /Commit

 

 

Give it a try and let us know what you think.

 

ref@

 

Comments (7)

  1. yup. _ says:

    Much needed for newbies like me.

  2. Anonymous says:

    ref@

    Excellent! Worked like a charm first time around. Thanks!

  3. Anonymous says:

    If you haven’t already, please refer to the “ Getting Started with Nano Server ” guide

  4. Jan Ringoš says:

    And thus I discovered the keyboard driver is actually loaded in Server Nano.
    Making this Startup.cmd run cmd.exe works although it's not a particularly bright idea security-wise.

  5. Jan Ringoš says:

    BTW guys, would it be possible to make MpCmdRun.exe (Windows Defender) run without, um, stealing the console? I would like to have ipconfig visible all the time, but periodically the scheduler starts the scan and it covers previous screen until it finishes.

  6. Tim Cerling says:

    Since the ping command in the Startup.cmd file is just to cause a delay, something that would be a little more obvious would be a command like:

    powershell start-sleep 10

    Adjust the number of seconds to whatever value you want.

Skip to main content