CS 302 - Programming Assignment 4

For this assignment you will write a "launcher" program that creates Windows processes. Write a console program that prompts the user with a list of the following five programs that come with every copy of Windows, notepad.exe, wordpad.exe, cmd.exe, calc.exe, and explorer.exe. Have the five programs numbered in the list from 1 to 5. Have the user choose one of the five programs by inputting a number between 1 and 5. Then your program should use the Win32 function CreateProcess() to start up the program that the user chose. After the process has been created, output a message that states the PID of the newly created process. After your program launches the user's choice, your program should once again prompt the user with the list of available programs and let the user launch another program. However, one of the five programs should be special. Mark the cmd.exe program in the menu with a * after its number. For the cmd.exe program, your launcher program should wait for cmd.exe to terminate before the launcher prompts the user for another choice. In other words, the launcher blocks after it launches cmd.exe and the launcher remains blocked until cmd.exe terminates. Your program should keep on letting the user launch programs until the user enters zero.

Here are a few additional requirements of your launcher. Your launcher program should use standard environment variables to refer to the above five programs in a way that is independent of any particular Windows installation. For example, some versions of Windows have a C:\Windows system directory, some a C:\WINNT system directory, some people have a C:\Program Files directory while others might have a D:\Program Files directory; your program should work independently of these kinds of choices. Relevant environment variables are, for example, ComSpec, SystemDrive, SystemRoot, ProgramFiles, HomeDrive, windir.

When your program launches the cmd.exe program, it should give the new console window the title "What is your command?". The console window should have light blue letters on a bright white background. (Note: I am purposely not telling you how to do these.)

Your program should print out reasonable error messages when something goes wrong (e.g., file not found). Use the error message function included in the example programs from the class lectures.

This assignment is due Wednesday, February 28.

Here are references to the relevant functions in the Win32 API (you can also look these up in the Win32 API online help file installed with Lcc-Win32).


Return to the main homework page.
Return to the CS 302 home page.


compliments and criticisms