Freigeben über


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

  • Anonymous
    January 01, 2003
    Much needed for newbies like me.
  • Anonymous
    January 01, 2003
    ref@

    Excellent! Worked like a charm first time around. Thanks!
  • Anonymous
    June 02, 2015
    If you haven’t already, please refer to the “ Getting Started with Nano Server ” guide
  • Anonymous
    June 11, 2015
    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.
  • Anonymous
    June 20, 2015
    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.
  • Anonymous
    June 22, 2015
    Nice article thanks a lot for sharing

    http://affordable-servers.com/blog/2015/06/22/how-to-limit-the-priviledges-a-reseller-in-web-host-manager/
  • Anonymous
    June 29, 2015
    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.