Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Self Deleting script

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,62200
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Self Deleting script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Self Deleting script - 7/7/2008 6:55:59 PM   
  4scriptmoni


Posts: 200
Score: 0
Joined: 5/3/2007
Status: offline
I need to delete my script once it finished running, has anybody everdone this?

_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net
 
 
Post #: 1
 
 RE: Self Deleting script - 7/7/2008 6:59:27 PM   
  4scriptmoni


Posts: 200
Score: 0
Joined: 5/3/2007
Status: offline
lol, should have searched google before posting, here is what I found but did not test it, yet



      

or


      

_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net

(in reply to 4scriptmoni)
 
 
Post #: 2
 
 RE: Self Deleting script - 7/8/2008 12:56:59 AM   
  GreatBarrier86

 

Posts: 71
Score: 0
Joined: 3/10/2008
Status: offline
i dont think the first one will work because the file would still be running when you tried to delete it.

What about

oShell.Run "cmd /c del " & WScript.ScriptFullName

< Message edited by GreatBarrier86 -- 7/8/2008 1:01:24 AM >

(in reply to 4scriptmoni)
 
 
Post #: 3
 
 RE: Self Deleting script - 7/8/2008 2:28:34 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
The first one works just fine. The scripting engine does not hold the file open with a lock during execution.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to GreatBarrier86)
 
 
Post #: 4
 
 RE: Self Deleting script - 7/8/2008 3:20:24 AM   
  GreatBarrier86

 

Posts: 71
Score: 0
Joined: 3/10/2008
Status: offline
Oh that's good to know. but will the Set objShell = nothing work since the script is being deleted before then?

Also, is that necessary? Because as soon as the execution finishes, which i assume would be there, it would clear the memory anyway.

(in reply to Rischip)
 
 
Post #: 5
 
 RE: Self Deleting script - 7/8/2008 3:25:32 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
The script is being run from memory. The file resides on disk. Therefore the cleanup after the delete is legit.

In general the script engine will cleanup after itself fairly well, but I write many LONG running scripts and generally cleanup after myself.

In this instance there is no particular reason to do it, but also no particular reason not to do it.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to GreatBarrier86)
 
 
Post #: 6
 
 RE: Self Deleting script - 7/8/2008 7:24:36 PM   
  4scriptmoni


Posts: 200
Score: 0
Joined: 5/3/2007
Status: offline
well my reason was simple, the script contatins passwords and I am running then remotely using psexec, so I copy then to the server call it using psexec...
but yes when I call with psexec, I also try to delete it from there, so I do it 2 times just to be sure...

_____________________________

Enterprise Microsoft Scripts
Exchange, Login/Logout Monitor,TS, Monitoring, Security, AD, etc...
http://www.felipeferreira.net

(in reply to Rischip)
 
 
Post #: 7
 
 RE: Self Deleting script - 7/9/2008 12:59:22 AM   
  GreatBarrier86

 

Posts: 71
Score: 0
Joined: 3/10/2008
Status: offline
Why not just do a while loop?

Do While oFSO.FileExists(sFileWithPassword)
objFSO.DeleteFile(sFileWithPassword)
Loop

(in reply to 4scriptmoni)
 
 
Post #: 8
 
 RE: Self Deleting script - 7/9/2008 1:05:32 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
Instead of copying a script with passwords in it, you should copy a stub script which runs the other script off of a file share.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to GreatBarrier86)
 
 
Post #: 9
 
 RE: Self Deleting script - 7/10/2008 4:48:14 AM   
  p0ng

 

Posts: 33
Score: 0
Joined: 6/18/2008
Status: offline
This will work:


      

(in reply to Rischip)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Self Deleting script Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts