WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Exit and Remove Current Scripts Folder


Developer:  ferchl les.ferch@jpmchase.com  
Posted:  Friday, January 05, 2007 04:53 PM  
; Exit and delete current script's folder.
; You must specify a folder name. This is for safety.
; Blindly deleting DirScript() would be very dangerous.

; It is designed for situations where you have an entire folder for your
; program that may contain any number of support files and subfolders and you
; wish to delete that whole folder on exit.


#DefineFunction ExitClean(Folder)
Temp = Environment("Temp")
DirChange(Temp)
z = @CRLF
s = `Set w=CreateObject("Wscript.Shell")`:z
s = s:`Set f=CreateObject("Scripting.FileSystemObject")`:z
s = s:`On Error Resume Next`:z
s = s:`Wscript.Sleep 2000`:z
s = s:`f.DeleteFolder "`:Folder:`"`:z
s = s:`f.DeleteFile Wscript.ScriptFullName`:z
Script = Temp:"\DeleteMe.vbs"
FilePut(Script,s)
Run("Wscript.exe",Script)
Exit
#EndFunction

; Test
IntControl(12,5,0,0,0) ; Terminate silently
IntControl(1003,0,0,0,0) ; No WinBatch Processing Window
Title = "Test"
BoxTitle(Title)
Pause(Title,"Click OK to proceed")
ExitClean("C:\Test")


Article ID:   W17215
File Created: 2007:07:03:14:28:52
Last Updated: 2007:07:03:14:28:52