Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Deleting a running script

by Bagarre (Sexton)
on Sep 16, 2003 at 16:24 UTC ( #291871=note: print w/replies, xml ) Need Help??


in reply to Re: Deleting a running script
in thread Deleting a running script

The killer is, it's a Windoz platform. Unlink would work like a charm if I was in a 'nix world. Windows puts a lock on the file and I can't even 'manualy' delete it from the command prompt while she's running :( I tried scheduling a job to do it for me just after the program finishes but, that opened another can of worms. I was hoping to take care of it from within the program itself.

Replies are listed 'Best First'.
Re: Re: Re: Deleting a running script
by Limbic~Region (Chancellor) on Sep 16, 2003 at 16:45 UTC
    Bagarre,
    waswas-fng gave you the answer. You need to have the last few lines of your program create a batch file. The batch file looks something like:
    del script.exe del batch.bat
    The final line of code would be:
    exec ("batch.bat");
    Why is it important for the executable to delete itself anyway?

    L~R

      Why is it important for the executable to delete itself anyway?
      I'm pretty sure he's writing an uninstaller.

      Now, you surely wouldn't want any traces of an uninstalled program left, if it were on your system, no?

        or a virus.... Big bloody virus it would be though.

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      The program is 'farmed' out and runs in the background without a gui or anything in order to not disturb or alert the user. (It's not a hacker tool. More of a config checker) Not alerting the user is a big ticket for this thing so, no pop-up windows or rebooting can be done. :( Once it's done, I dont want it floating around on the computers so, it needs to delete itself. I have the "Farmer" program going back around and removing it now but, I wanted a more elegant solution instead of constantly checking if the tool has finished.. blah blah. I tried the batch file method and back tic'd it to the shell but, always got a 'permission denied' due to the process locking the file. Thanks
        Bagarre,
        I think you forgot to login. The `batch.bat` method won't work. You have to exec. I verified that it works.

        Cheers - L~R

Re: Re: Re: Deleting a running script
by phydeauxarff (Priest) on Sep 16, 2003 at 16:41 UTC
    There is a way to do this by setting a value in the registry to run the program on the next reboot and then forcing a reboot on the system.

    I can't offer any additional guidance since I am certainly no Windows Programming Guru....except to say that I know this can be done because I have seen it in commercial installer programs.

    I found this artcle on forcing a reboot on http://www.devx.com/ which is not a perl solution but perhaps there is a way to do this with one of the Win32 modules on CPAN

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://291871]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2021-11-26 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?