Computing.Net > Forums > Programming > Batch file waits for Notepad

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch file waits for Notepad

Reply to Message Icon

Name: Pthomass
Date: August 17, 2005 at 06:41:33 Pacific
OS: Win XP pro SP2
CPU/Ram: P4 3.0 GHz 504MB DRam
Comment:

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%\System32

After 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%\ShutdownForUPS

Thanks in advance



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: August 17, 2005 at 13:09:46 Pacific
Reply:

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.


0

Response Number 2
Name: Pthomass
Date: August 18, 2005 at 01:42:27 Pacific
Reply:

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?


0

Response Number 3
Name: IVO
Date: August 18, 2005 at 12:14:21 Pacific
Reply:

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.


0

Response Number 4
Name: Pthomass
Date: August 19, 2005 at 01:34:10 Pacific
Reply:

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


0

Response Number 5
Name: IVO
Date: August 19, 2005 at 06:25:25 Pacific
Reply:

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.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch file waits for Notepad

batch file programming www.computing.net/answers/programming/batch-file-programming/17121.html

Batch file input for logevent.exe www.computing.net/answers/programming/batch-file-input-for-logeventexe/15380.html

batch file to call reg files? www.computing.net/answers/programming/batch-file-to-call-reg-files/8298.html