O'Reilly logo

Getting Started with Nano Server by Charbel Nemnom

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Run commands on first boot

SetupComplete.cmd is a command file that, if found on boot by Windows under this location (C:\Windows\Setup\Scripts\), will be executed once and then never again, even if it's still in the same location afterward.

In the following example, we are setting a static IP address using command prompt. The trick here is that we are executing a PowerShell command by adding PowerShell.exe in the .cmd file. Because there is no PowerShell environment here, we follow this by adding -command and everything after that is a single command placed between quotation marks. It's very important for the command to be a single line, because every PowerShell.exe has its own environment. Therefore, we put everything related to setting ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required