Question
Write a console program that prompts the user with a list of the following five programs that come with Windows, notepad.exe, cmd.exe, nslookup.exe, charmap.exe, and
Write a console program that prompts the user with a list of the following five programs that come with Windows, notepad.exe, cmd.exe, nslookup.exe, charmap.exe, and wordpad.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 CreateProcessA() 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 two paragraphs for two exceptions). Your program should keep on letting the user launch programs until the user enters zero.
The program cmd.exe is 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, your 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 your launcher should prompt the user for another choice.
The program nslookup.exe is also special. Mark the nslookup.exe program in the menu with a # in front of its number. The nslookup.exe program is, like your launcher, a console application (that is, it's not a GUI program). For the nslookup.exe program, your launcher program should NOT create a new console window for nslookup.exe to run in. Your launcher should run nslookup.exe in your launcher's own console window. While the nslookup.exe program is running, it will share the console with your launcher. That means that your launcher needs to, once again, wait for nslookup.exe to terminate before it issues a new prompr to the user (otherwise, your lancher and nslookup.exe will fight with each other over the console window, and the fight will not end well). When nslookup.exe terminates, your launcher can immediately prompt the user for a new choice. You should terminate nslookup by using an "exit" command.
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.
When your program launches the cmd.exe program, it should give the new console window the title "What is your command?". The console prompt should be "Speak Up:>". The console window should have light yellow letters on a red background. The console window should be positioned with its top left corner at the top left corner of your desktop.(Note: I am purposely not telling you exactly how to do these. You will need to use a combination of parameters to CreateProcessA(), entries in the STARTUPINFO data structure, and using the _putenv() function to set environment variables.)
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started