Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Need help with writing a BATCH file to uninstall XP Killbits..  (Read 2554 times)

0 Members and 1 Guest are viewing this topic.

Maelstrum

  • Guest
Need help with writing a BATCH file to uninstall XP Killbits..
« 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

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Need help with writing a BATCH file to uninstall XP Killbits..
« Reply #1 on: November 04, 2009, 10:25:33 AM »
Quote
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.

Quote
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?

The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Need help with writing a BATCH file to uninstall XP Killbits..
« Reply #2 on: November 04, 2009, 11:16:00 AM »
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...

Code: [Select]
: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:

Code: [Select]
: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.
I was trying to dereference Null Pointers before it was cool.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Need help with writing a BATCH file to uninstall XP Killbits..
« Reply #3 on: November 04, 2009, 02:39:46 PM »
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).

Code: [Select]
:start
echo create a text file
notepad file.txt
move file.txt archive\
goto start
Quote
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)
« Last Edit: November 04, 2009, 03:08:34 PM by Sidewinder »
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Need help with writing a BATCH file to uninstall XP Killbits..
« Reply #4 on: November 05, 2009, 09:56:43 AM »
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.



I was trying to dereference Null Pointers before it was cool.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Need help with writing a BATCH file to uninstall XP Killbits..
« Reply #5 on: November 05, 2009, 09:59:29 AM »
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)
I was trying to dereference Null Pointers before it was cool.