Creating a self deleting executable using .NET 
Author Message
 Creating a self deleting executable using .NET

I am trying to create an application for the Windows Mobile 5.0 (or higher)
platform. One of the features of the application is that it has a panic
button that automatically closes down the application and deletes the
executable.

I have been trying to find a technical solution for this feature but it has
proven to be much harder than I thought. The problem is that the physical
executable file is locked and can't be deleted as long as the executable is
running.

I found some quite interesting articles explaining the problem in more
detail and also explaining some possible solutions. An example of a very
usefull article on this subject can be found on:
http://www.*-*-*.com/

Unfortunately the solutions in the article require C++ and I am trying to
achieve a solution that will work in VB.NET or C#.NET. Is there anybody who
can help me a bit further with this problem ? Any help is appreciated.



Wed, 09 May 2012 04:59:01 GMT  
 Creating a self deleting executable using .NET
This is a VB6 and earlier group(VB Classic). VB.Net and all dotnet groups
have either "dotnet" or "vsnet" in the group name. Please use the following
group instead:




Wed, 09 May 2012 05:03:40 GMT  
 Creating a self deleting executable using .NET


Quote:
>I am trying to create an application for the Windows Mobile 5.0 (or higher)
> platform. One of the features of the application is that it has a panic
> button that automatically closes down the application and deletes the
> executable.

> I have been trying to find a technical solution for this feature but it
> has
> proven to be much harder than I thought. The problem is that the physical
> executable file is locked and can't be deleted as long as the executable
> is
> running.

> I found some quite interesting articles explaining the problem in more
> detail and also explaining some possible solutions. An example of a very
> usefull article on this subject can be found on:
> http://www.catch22.net/tuts/selfdel

> Unfortunately the solutions in the article require C++ and I am trying to
> achieve a solution that will work in VB.NET or C#.NET. Is there anybody
> who
> can help me a bit further with this problem ? Any help is appreciated.

Well, you're not going to be able to have the application delete itself, as
you know, which means that some other applicaiton is going to have to do it.

I would create a "launch" application that is the one that actually runs
when the program is started.  This application would spawn a new process,
which then executes your "main" application in that new process.

When your panic button is pressed, it is the "launch" application that
handles it by shutting down the secondary process (the one running your main
application) and then deleting the file (which you could now do because the
application is no longer running).

Here's some code to get you started:

Sub Main()
        'Launch main application in a new process...
        If System.IO.File.Exists("path to main application here")  Then
             mainAppProc = System.Diagnostics.Process.Start("path to main
application here")

             'If you don't set this, you won't get event notifications
because the events won't be raised.
             mainAppProc.EnableRaisingEvents = True
        End If
End Sub

Sub PanicButton_Click() Handles btnPanic.Click
        'Stop the process...

        'Killing a process can have serious ramifications!
        If Not mainAppProc .HasExited Then
            calcProc.Kill()
        End If

        'Delete the main application
        Dim FileToDelete As String
        FileToDelete = "C:\testDelete.txt"
        If System.IO.File.Exists(FileToDelete)  Then
System.IO.File.Delete(FileToDelete)

        'Shut down the launch application
        Application.Quit
En Sub

In the end, the main application's assembly should be shut down and deleted,
but you will still have the "launch" application resident on the device.

-Scott



Wed, 09 May 2012 05:22:04 GMT  
 Creating a self deleting executable using .NET

Hey, A$$hole, this is not a .Nxt group.  Post your code in the approprate
forum, which ain't here.


|

| >I am trying to create an application for the Windows Mobile 5.0 (or
higher)
| > platform. One of the features of the application is that it has a panic
| > button that automatically closes down the application and deletes the
| > executable.
| >
| > I have been trying to find a technical solution for this feature but it
| > has
| > proven to be much harder than I thought. The problem is that the
physical
| > executable file is locked and can't be deleted as long as the executable
| > is
| > running.
| >
| > I found some quite interesting articles explaining the problem in more
| > detail and also explaining some possible solutions. An example of a very
| > usefull article on this subject can be found on:
| > http://www.catch22.net/tuts/selfdel
| >
| > Unfortunately the solutions in the article require C++ and I am trying
to
| > achieve a solution that will work in VB.NET or C#.NET. Is there anybody
| > who
| > can help me a bit further with this problem ? Any help is appreciated.
|
| Well, you're not going to be able to have the application delete itself,
as
| you know, which means that some other applicaiton is going to have to do
it.
|
| I would create a "launch" application that is the one that actually runs
| when the program is started.  This application would spawn a new process,
| which then executes your "main" application in that new process.
|
| When your panic button is pressed, it is the "launch" application that
| handles it by shutting down the secondary process (the one running your
main
| application) and then deleting the file (which you could now do because
the
| application is no longer running).
|
| Here's some code to get you started:
|
| Sub Main()
|        'Launch main application in a new process...
|        If System.IO.File.Exists("path to main application here")  Then
|             mainAppProc = System.Diagnostics.Process.Start("path to main
| application here")
|
|             'If you don't set this, you won't get event notifications
| because the events won't be raised.
|             mainAppProc.EnableRaisingEvents = True
|        End If
| End Sub
|
| Sub PanicButton_Click() Handles btnPanic.Click
|        'Stop the process...
|
|        'Killing a process can have serious ramifications!
|        If Not mainAppProc .HasExited Then
|            calcProc.Kill()
|        End If
|
|        'Delete the main application
|        Dim FileToDelete As String
|        FileToDelete = "C:\testDelete.txt"
|        If System.IO.File.Exists(FileToDelete)  Then
| System.IO.File.Delete(FileToDelete)
|
|        'Shut down the launch application
|        Application.Quit
| En Sub
|
| In the end, the main application's assembly should be shut down and
deleted,
| but you will still have the "launch" application resident on the device.
|
| -Scott
|
|



Wed, 09 May 2012 05:24:38 GMT  
 Creating a self deleting executable using .NET
Go back to beating your wife and kids.



Quote:

> Hey, A$$hole, this is not a .Nxt group.  Post your code in the approprate
> forum, which ain't here.



> |


> | >I am trying to create an application for the Windows Mobile 5.0 (or
> higher)
> | > platform. One of the features of the application is that it has a
> panic
> | > button that automatically closes down the application and deletes the
> | > executable.
> | >
> | > I have been trying to find a technical solution for this feature but
> it
> | > has
> | > proven to be much harder than I thought. The problem is that the
> physical
> | > executable file is locked and can't be deleted as long as the
> executable
> | > is
> | > running.
> | >
> | > I found some quite interesting articles explaining the problem in more
> | > detail and also explaining some possible solutions. An example of a
> very
> | > usefull article on this subject can be found on:
> | > http://www.catch22.net/tuts/selfdel
> | >
> | > Unfortunately the solutions in the article require C++ and I am trying
> to
> | > achieve a solution that will work in VB.NET or C#.NET. Is there
> anybody
> | > who
> | > can help me a bit further with this problem ? Any help is appreciated.
> |
> | Well, you're not going to be able to have the application delete itself,
> as
> | you know, which means that some other applicaiton is going to have to do
> it.
> |
> | I would create a "launch" application that is the one that actually runs
> | when the program is started.  This application would spawn a new
> process,
> | which then executes your "main" application in that new process.
> |
> | When your panic button is pressed, it is the "launch" application that
> | handles it by shutting down the secondary process (the one running your
> main
> | application) and then deleting the file (which you could now do because
> the
> | application is no longer running).
> |
> | Here's some code to get you started:
> |
> | Sub Main()
> |        'Launch main application in a new process...
> |        If System.IO.File.Exists("path to main application here")  Then
> |             mainAppProc = System.Diagnostics.Process.Start("path to main
> | application here")
> |
> |             'If you don't set this, you won't get event notifications
> | because the events won't be raised.
> |             mainAppProc.EnableRaisingEvents = True
> |        End If
> | End Sub
> |
> | Sub PanicButton_Click() Handles btnPanic.Click
> |        'Stop the process...
> |
> |        'Killing a process can have serious ramifications!
> |        If Not mainAppProc .HasExited Then
> |            calcProc.Kill()
> |        End If
> |
> |        'Delete the main application
> |        Dim FileToDelete As String
> |        FileToDelete = "C:\testDelete.txt"
> |        If System.IO.File.Exists(FileToDelete)  Then
> | System.IO.File.Delete(FileToDelete)
> |
> |        'Shut down the launch application
> |        Application.Quit
> | En Sub
> |
> | In the end, the main application's assembly should be shut down and
> deleted,
> | but you will still have the "launch" application resident on the device.
> |
> | -Scott
> |
> |



Wed, 09 May 2012 05:31:12 GMT  
 Creating a self deleting executable using .NET


 > Here's some code to get you started

Quote:
> Sub Main()
>        'Launch main application in a new process...
>        If System.IO.File.Exists("path to main application here")

Go play somewhere else, Scotty. You're just a troll. This is a Classic VB
newsgroup and you are not wanted here.

Mike



Wed, 09 May 2012 05:46:25 GMT  
 Creating a self deleting executable using .NET


| Go back to beating your wife and kids.

No need.  I'm having too much fun beating on yours.



Wed, 09 May 2012 05:55:53 GMT  
 Creating a self deleting executable using .NET




|
| > Here's some code to get you started
| > Sub Main()
| >        'Launch main application in a new process...
| >        If System.IO.File.Exists("path to main application here")
|
| Go play somewhere else, Scotty. You're just a troll. This is a Classic VB
| newsgroup and you are not wanted here.
|

He's clearly compensating.  His wife told me he's got a little tiny{*filter*} and
doesn't know how to use it and is often mistaken for a woman.  I don't know
how he lives that down.  Sad.



Wed, 09 May 2012 05:58:04 GMT  
 Creating a self deleting executable using .NET

Quote:

>I am trying to create an application for the Windows Mobile 5.0 (or higher)
>platform. One of the features of the application is that it has a panic
>button that automatically closes down the application and deletes the
>executable.

Why does this sound like you're trying to build malware?  

--
"You're in probably the wickedest, most corrupt city, most
Godless city in America." -- Fr Mullen, "San Francisco"



Wed, 09 May 2012 06:10:04 GMT  
 Creating a self deleting executable using .NET

| >I am trying to create an application for the Windows Mobile 5.0 (or
higher)
| >platform. One of the features of the application is that it has a panic
| >button that automatically closes down the application and deletes the
| >executable.
|
| Why does this sound like you're trying to build malware?
|

Most of us more intelligent participants probably read between the lines and
saw this as well.  However, you're talking about Scott here, who was more
concerned about trolling this community with his .Nxt evangelism than taking
into account the nature of the request.  This is what happens when brothers
and sisters breed and produce complete idiots.  This is probably why
McCarthy took little Scottee under his wing and trained his to become the
latest .Nxt troll; they have that mongoloidism in common.



Wed, 09 May 2012 06:43:14 GMT  
 Creating a self deleting executable using .NET


Quote:


> > Here's some code to get you started
>> Sub Main()
>>        'Launch main application in a new process...
>>        If System.IO.File.Exists("path to main application here")

> Go play somewhere else, Scotty. You're just a troll. This is a Classic VB
> newsgroup and you are not wanted here.

> Mike

You're not wanted here either, but you keep sticking around.


Wed, 09 May 2012 06:45:20 GMT  
 Creating a self deleting executable using .NET



Quote:



> | Go back to beating your wife and kids.

> No need.  I'm having too much fun beating on yours.

That's obvious.


Wed, 09 May 2012 06:44:47 GMT  
 Creating a self deleting executable using .NET


Quote:

>>I am trying to create an application for the Windows Mobile 5.0 (or
>>higher)
>>platform. One of the features of the application is that it has a panic
>>button that automatically closes down the application and deletes the
>>executable.

> Why does this sound like you're trying to build malware?

Or "{*filter*}ware"?


Wed, 09 May 2012 06:45:51 GMT  
 Creating a self deleting executable using .NET



Quote:



> | >I am trying to create an application for the Windows Mobile 5.0 (or
> higher)
> | >platform. One of the features of the application is that it has a panic
> | >button that automatically closes down the application and deletes the
> | >executable.
> |
> | Why does this sound like you're trying to build malware?
> |

> Most of us more intelligent participants probably read between the lines
> and
> saw this as well.  However, you're talking about Scott here, who was more
> concerned about trolling this community with his .Nxt evangelism than
> taking
> into account the nature of the request.  This is what happens when
> brothers
> and sisters breed and produce complete idiots.  This is probably why
> McCarthy took little Scottee under his wing and trained his to become the
> latest .Nxt troll; they have that mongoloidism in common.

What a well thought out reply that has no facts in it (go look up the
definition of evangelism because you don't use it correctly) or relevance to
the post.  In fact, you only come out of the woodwork to sling profanity and
insults.  Very troll-like behavior if you ask me.


Wed, 09 May 2012 06:51:47 GMT  
 Creating a self deleting executable using .NET


|




| >
| > > Here's some code to get you started
| >> Sub Main()
| >>        'Launch main application in a new process...
| >>        If System.IO.File.Exists("path to main application here")
| >
| > Go play somewhere else, Scotty. You're just a troll. This is a Classic
VB
| > newsgroup and you are not wanted here.
| >
| > Mike
|
| You're not wanted here either, but you keep sticking around.

Says who?  You?  Haven't you yet figured out by the numerous replies from
people you've irked that it's you who is not wanted here?  Your opinion

place you're really wanted.  :-)



Wed, 09 May 2012 06:52:48 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. self deleting executable?

2. Can VB create self-extracting executables?

3. fso.delete(self) - how to refer to self?

4. deleting dynamically created controls in runtime using vb.net

5. using self created controls

6. Help with Self Executable File

7. VB 4.0 Self Contained Executable

8. VB 4.0 Self Contained Executable

9. self executable program

10. Creating executable and using Access tables

11. what create table using ADO.NET to VB.NET

12. .NET executables decompilers to VB.NET?

 

 
Powered by phpBB® Forum Software