My PKB

Entries categorized as ‘CLI’

How to programmatically set the processor affinity of an application

September 16, 2007 · 1 Comment

One of the user I support runs an older CAD application that doesn’t work properly on computers using a dual core processor. It creates ghosting artifacts when he draws and eventually crashes the application. The trick is to limit the application’s process to only one processor (or one core). To do it manually:

  1. Launch the application
  2. Locate the application’s process in the Task Manager (type taskmgr from the Run command or press Ctrl+Alt+Delete)
  3. Right-click on the process and select Set Affinity
  4. Uncheck all the selected CPUs except one.

It works well, but it needs to be done every time the application is launched.

To do it automatically, I downloaded a free command line utility from a company called Beyond Logic: process.exe. To have a process named ExampleAppProcess.exe use only CPU 1, type:

process -a ExampleAppProcess.exe 01

So, I copied process.exe in a folder and added the path to this folder to the PATH environment variable. Then, I opened Notepad and typed:

cd c:\Program Files\ExampleAppFolder
start ExampleApp.exe
process -a ExampleAppProcess.exe 01

I saved this file as Affinity.cmd and added a shortcut to it on the Desktop. I changed the name and the icon of the shortcut to match the one used by the original application, and then deleted the original shortcut.

Now my user doesn’t have to do anything special: He double-clicks on what appears the be the same shortcut as before, but now his application works.

Categories: CLI · Software

How to launch Outlook Express from the command line

July 8, 2007 · 3 Comments

Even if you “uninstall” Outlook Express via Add/Remove Windows Components (type control appwiz.cpl,,2 at the command prompt), it is still very much installed. The icons and shortcuts pointing to it are gone but you can still easily launch Outlook Express by typing msimn at the command line.

More info here: OLEXP: Command Line Options for Outlook Express

Also, the site to go to for everything Outlook Express: Inside Outlook Express

Categories: CLI · Software

Keep Windows on time with the built-in Windows Time service

February 6, 2007 · No Comments

I had to keep a W2K machine on time as its main job is to control clocks in different locations. It turns out that Windows as a built-in SNTP client that can be set to retrieve the time from public SNTP servers.

The idea is to give Windows a list of time servers to check and then restart the Windows Time service for the change to take effect.

So, first you need a list of available SNTP time servers.

Then, you use the net time command to enter a list of time servers, e.g.:

C:\>net time /setsntp:"ns.scruz.net ntp.ucsd.edu ntp1.mainecoon.com"

Finally, you restart the Windows Time service:

C:\>net stop W32Time
C:\>net stop W32Time

Categories: CLI · Software

How to deal with “CMD does not support UNC paths as current directories“

February 1, 2007 · 3 Comments

The solution is to use pushd instead of cd to change the current directory to a share accessed via a UNC path (e.g.: >pushd \\myserver\myshare).
Use popd when done.

More info on the Microsoft Web site.

Categories: CLI · Software