Author Archives: robot

How to parse WMIC output with Python

The Windows Management Instrumentation Command-line (WMIC) is a command-line and scripting interface for Windows Management Instrumentation (WMI). For example, if you are interested in getting Caption, Description, and Vendor of Python installed. Simply run the following command.

The output will be similar to below:

The first line is the headers, and is followed… Read More »

How to set an environment variable to the local IP address in Windows

This is a simple command batch to get the local IP address from ipconfig command.

The first line is to extract IP address from ipconfig command. The second line is just to trim the leading white space. To run the command line directly in a command prompt, remember to change %%i to %i.

How to keep the local console open for Windows Server 2012

In the previous post it has the instruction on how to keep the local console open. However, it doesn’t work well for Windows Server 2012. Somehow when you remote desktop the machine, the task in Task Scheduler is triggered. It is not only triggered at disconnection, but also connection of a remote session. It looks… Read More »

How to keep Windows local desktop open

To run Windows UI automation, the machine has to be in unlock state. However, the test machine may be located in a data center, a cloud, or a locked lab. Remote desktop is the best way to acces it. What will happen when remote desktop is disconnected? Windows’s local console is locked. If UI automation… Read More »

How to enable auto logon on Windows 7

Run the program netplwiz. Uncheck the box “Users must enter a user name and password to use the computer.” After OK or Apply is clicked, a dialog box will pop up and ask for the user name and password for auto logon.

How to list files in a directory using Windows commands

To enumerate files in the current directory in a command prompt, use the following command line.

Here the command dir is used with a for loop. The argument /b is to output bare format. To use the for loop command in a batch file, the iterator %I has to be changed to %%I

If… Read More »

How to run a Window command repeatedly forever

Say, you want to run the command “echo Hello, World” repeatedly forever. A goto command can be used to create a forever loop.

Using ping here is to add 5-second sleep in the loop since there is no built-in command for sleeping. A little sleep may be required in order to break the execution… Read More »

Try out Crayon Syntax Highlighter