🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #15258

Re: Spawning and Deleteing an exe file

#15258
From: Ed Mulroy [TeamB]
Date: Mon, 14 Jul 2003 11:04
28 lines
2265 bytes
You might try using CreateProcess and telling it to create a new process
group.  Windows protects the exe files of executing programs.

When using the spawn* family that program will default to being part of the
same process group as the program that spawned it.  The file may be
protected until the calling process is ended.  With a new process group you
have a chance of being able to delete it after it finishes running.

You will need to use some semaphore or mutex call such as
WaitForSingleObject to detect when the program is no longer running.

When asking something like this it would be useful if you mentioned what
operating system and version and what compiler and version are being used.

.  Ed

> Steve Craig wrote in message
> news:3f127f9c@newsgroups.borland.com...
> I want to spawn and then delete an executeable.  So I tried
> something like...
>
> spawnl(P_WAIT, "MyProg.exe", "MyProg.exe", NULL);
> DeleteFile("MyProg.exe");
>
> However, althought the file became inaccessible, it did not
> actually vanish until I rebooted by pc.  (I also tried using
> CreateProcess() with identical results). I really do need
> the file to disappear  immediately, how can I cheive this?
Technical Details
Message-ID: <3f128e58@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f127f9c@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,8871a81884d35a65
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-14 04:10:27 PST
From: "Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f127f9c@newsgroups.borland.com>
Subject: Re: Spawning and Deleteing an exe file
Date: Mon, 14 Jul 2003 07:04:33 -0400
Lines: 30
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 206.228.162.42
Message-ID: <3f128e58@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1058180696 206.228.162.42 (14 Jul 2003 04:04:56 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewspeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail