Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I made a batch file that I put in a WinZip self extractor. The idea is that the zip-file extracts to a folder, and then the bat file gets executed. It copies files to
"C:\Program Files\ShutdownForUPS"
"%UserProfile%\Start Menu\Shutdown For UPS"
and to "%Windir%\System32After that it needs to delete the original files that the zip-file extracted. I do this by first deleting the files in all folders and subfolders and then deleting the folders itself.
Afterwards I CALL a Readme file, and that is where the problem is. When the ReadMe file is called, the DOS window remains in the background. Only when I close the file, the DOS window closes (end of Bat file).
Is it possible to close the DOS window without closing the Readme file?
Is it also possible to delete the bat file automatically when all is executed???Here is the bat file
set currentdir=%cd%
mkdir "c:\Program Files\ShutdownForUPS"
copy %currentdir%\shutdownforups\shutdownforups.exe "C:\Program Files\ShutdownForUPS"
copy %currentdir%\shutdownforups\shutdown.bat "C:\Program Files\ShutdownForUPS"
copy %currentdir%\shutdownforups\stop.bat "C:\Program Files\ShutdownForUPS"
copy %currentdir%\shutdownforups\ReadMe.txt "C:\Program Files\ShutdownForUPS"
copy %currentdir%\shutdownforups\shutdown.exe %Windir%\System32
copy %currentdir%\shutdownforups\richtx32.ocx %Windir%\System32
mkdir "%UserProfile%\Menu Start\Programma's\ShutdownForUPS"
copy %currentdir%\shutdownforups\StartMenu\ShutdownForUPS.lnk "%UserProfile%\Menu Start\Programma's\ShutdownForUPS"
rem Call "C:\Program Files\ShutdownForUPS\ReadMe.txt
del %currentdir%\ShutdownForUPS\StartMenu /f /q
del %currentdir%\ShutdownForUPS /f /q
rd %currentdir%\ShutdownForUPS\StartMenu
rd %currentdir%\ShutdownForUPSThanks in advance

About your first question just replace
Call "C:\Program Files\ShutdownForUPS\ReadMe.txt"
with
Start "" "C:\Program Files\ShutdownForUPS\ReadMe.txt"
Beware do not miss the "" after Start!
About your question on deleting the batch file the answer is NO, a batch file can't delete itself.

thanks, it worked
So, I should manually delete the batch file? Or should I copy a batch file to the Program Files folder, run that from the first batch and let that second file delete the first batch file?Is there no other way?

There is a way to work around my posted NO to self-deleting batch file, but a third party utility is required.
First download Sleep.exe (freeware) from
http://www.computerhope.com/dutil.htm
don't care the warning it is for DOS kernel systems, it works fine under XP/2K too.
Then code the following as your last statement in the batch
Start "" /Min Cmd /C "Sleep 5 & Del %0.bat"
You can code a low time lag (here it is five secs), but the starter batch must be gone out before the killer-child process trigs the shot.

Hi,
Thanks for your reply. But I think I'm going to let that batch file leave it where it is. Normally it should be in the TEMP folder, and most users empty that folder occasionally.
Howerver, I now made an uninstall batch file, and when I use that, it will delete all files and folders, EXCEPT for the folder under Program Files and its own.(this is regarding your post)
Is it possible to let the batch file open a little warning window that says that Uninstall was completed and that the user needs to delete the folder manually????

I do not full understand your request as you just answered by yourself in your first post.
Type in a txt document using notePad holding your warning mesages and then code as your last statement in the uninstall batch
Start "" UNINSTALL.TXT
assuming UNINSTALL.TXT us the document to be displayed. Another way to achieve that using strictly batch commands is
Start "UNINSTALL WARNING" Cmd /C "Type UNINSTALL.TXT & Pause > Nul"
In that case you need to end your messages with a line
Press any key to close the window...
and you are limited to 25 lines.
The UNINSTALL.TXT document CAN be deleted while is displayed, i.e. it can be made resident in one of the folders candidate to be erased.
This should fit your question, otherwise post again.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |