Computer Hope
Microsoft => Microsoft Windows => Windows XP => Topic started by: Maelstrum on November 04, 2009, 09:56:22 AM
-
Hello all. I have batch file that I have written that works very well but it requires me to press OK if it cannot find a file for it to continue. Here is one of the lines I am using:
start /w C:\WINDOWS\$NtUninstallKB974455$\spuninst\spuninst.exe
What I would like to know is:
1. ) What statement would I put in to have it continue without hitting "OK" if it cannot find the file to uninstall?
2. ) Once it is completes I would like a pop-up to say COMPLETED SUCCESSFULLY.
Any ideas?
Thank you,
Maelstrum
-
What statement would I put in to have it continue without hitting "OK" if it cannot find the file to uninstall?
I doubt you can. The OK screen is issued by the program spuninst and is not an external instruction.
Once it is completes I would like a pop-up to say COMPLETED SUCCESSFULLY.
Batch code does not do pop-ups, but you can issue a message on the console using echo.
8)
If the /w switch is for the wait parameter, I think you have to spell it out. Someday someone will have to explain the /wait parameter to me. Why not just run the started commands in-line?
-
I doubt you can. The OK screen is issued by the program spuninst and is not an external instruction.
Batch code does not do pop-ups, but you can issue a message on the console using echo.
8)
If the /w switch is for the wait parameter, I think you have to spell it out. Someday someone will have to explain the /wait parameter to me. Why not just run the started commands in-line?
well the wait parameter will be important if you want to know when the program is done. for example, think of a program that executes notepad, archives the file notepad made, and repeats. Assume also that it has the logic to change the file name each iteration or something...
:start
echo create a text file
notepad file.txt
move file.txt archive\
goto start
this will simply start notepad until memory is exhausted.
with wait:
:start
echo create a text file
start /w notepad file.txt
move file.txt archive\
goto start
it works as required.
Also, I believe the installation packages posess either a /s or /q switch for silent operation.
-
You are correct about the spuninst switches. You can use either /quiet for quiet mode (no user interaction or display) or the /passive switch (unattended mode).
:start
echo create a text file
notepad file.txt
move file.txt archive\
goto start
this will simply start notepad until memory is exhausted.
Not quite. After the echo statement is executed, notepad will launch and the batch file will wait for notepad to be exited before executing the move statement. Notepad and the cmd interpreter execute in separate address spaces, with the batch file being interpreted and executed within the cmd.exe address space; when notepad terminates, Windows will free up any memory used by the notepad task and proceed to the move instruction. The memory used is not cumulative.
I still fail to see the difference between start /wait and running a program in-line.
8)
-
START was first released on windows 95.
Windows 9x did not run programs "in-line" and automatically ran them out of process.
The change for NT was that the command interpreter now uses "WaitForSingleObject" on the returned ProcessID from CreateProcess() after executing the program. In this case, notepad.
Therefore, START was essentially created originally to allow for synchronous execution of external programs, such as notepad. Now, with NT we can use it to perform the same asynchronous execution that was provided by default with 9x. So yes, the /WAIT parameter is redundant in the context of the NT command-line.
-
Notepad and the cmd interpreter execute in separate address spaces, with the batch file being interpreted and executed within the cmd.exe address space; when notepad terminates, Windows will free up any memory used by the notepad task and proceed to the move instruction. The memory used is not cumulative.
Yes, notepad is notepad.exe, cmd is cmd.exe; separate. However, assume for the moment we are running on 9x (because I was unaware that the behaviour changed to default to what used to require a start /wait). in that case, notepad would constantly be executed; the interpreter does not wait for the program to finish with 9x. Eventually, memory would be exhausted due to all the notepad windows. (not necessarily from all the programs running, since every notepad program will share all the same executable code pages)