Question: Write a console program that prompts the user with a list of the following five programs that come with Windows, notepad.exe, wordpad.exe, cmd.exe, calc.exe, and
Write a console program that prompts the user with a list of the following five programs that come with 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 Windows 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 (but see the next paragraph for an exception). Your program should keep on letting the user launch programs until the user enters zero.
One of the five programs should be special. Mark the cmd.exe program in the menu with a * in front of its number. For the cmd.exe program, your launcher program should wait for the launched cmd.exe process to terminate. In other words, the launcher blocks after it launches the cmd.exe process and the launcher waits (i.e., remains blocked) until the cmd.exe process terminates. When cmd.exe terminates, your program should look up the cmd.exe exit value and output a message that states the exit value. Then the launcher should prompt the user for another choice.
Here are a few additional requirements of your launcher. Your launcher program should use standard Windows environment variables to create command lines for 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 and some have 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. Below are two references that list a number of standard Windows environment variables.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
