Windows - Release & Renew IP in one step?

Is a batch file the only way to release and renew an IP in one step?

ipconfig /release
ipconfig /renew

I unfortunately have to admin some Windows servers using Remote Desktop. Obviously if I type ipconfig /release, then I'll loose my connection and won't be able to ipconfig /renew. Obviously this can be done with .bat files, but I wanted to ask the pros just to see if there were any other tricks to doing it in the Windows server world.


Solution 1:

Most people I think just either use static IP addresses for servers, or fixed DHCP assignments, and don't change IP addresses outside of scheduled reboots (Changing endpoints on running servers=bad). A bat file seems the simplest solution, but honestly even a straight up release should autorenew an IP address before the remote desktop session times out.

Solution 2:

Combine the two commands into one

ipconfig /release && ipconfig /renew

Microsoft > Docs > PowerShell > Scripting > What's New > What's new in Powershell 7.x > What's new in Powershell 7.0 > Pipeline chain operators

The && operator executes the right-hand pipeline, if the left-hand pipeline succeeded.

Solution 3:

Use AT command. Example AT 12:58 ipconfig /release

AT 12:59 ipconfig /renew (this is useful when connecting with psexec, because it does not handle && commands)