Solved

How to create  a program that destroy ifself on button close, and reactive itself on running a script.

Posted on 2012-03-11
11
172 Views
Last Modified: 2012-03-26
I have a form in VB.Net, it inserts the data into database.
I want when i click on close button, it should get deleted or hidden in such a manner that no one should be able to locate it, i.e exe file.
And when i run a script, it should get reactivated.
Is it possible.
Do we have any chaining process as we used to have in Qbasic. If any1 know this.
0
Comment
Question by:searchsanjaysharma
11 Comments
 
LVL 17

Expert Comment

by:nepaluz
ID: 37707174
To close the applcation, in the Button's click event, call Me.Close()
To start the application from a script, call the application.start equivalent from the script. If you pass any arguments to the application, make sure you handle them in the main thread's Sub New()
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 37707204
You could create an Application Setting flag, a boolean, (which is stored internally and gets persisted across runs) that determines if the app should simply exit without doing anything.  You could set that flag when the app is closed.  From the script, you can call the app and pass it a parameter that tells it run normally.  Then, if the app is run directly without the parameter, it will simply exit.
0
 

Author Comment

by:searchsanjaysharma
ID: 37707252
This i also know. i want a script. secondly, i have to destroy the application not just close the window.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 37707403
How can the program be recreated if it was destroyed?!...

Also, you can't destroy or rename the app while it is running (or in the act of closing).  This would have to be done from a secondary application (or script).

Can you give more details about what you're actually doing?
0
 

Author Comment

by:searchsanjaysharma
ID: 37707418
Just take the following example.
I have a calculator. Ok. When i close it should get hidden or destroyed. or rename. When i run another script it should be again activated
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 37707432
What's keeping the user from running the script that re-activates it?...

By "script", are you talking VBScript (.vbs)?  You can launch the app with a script that waits for the app to exit and then renames it.
0
 

Author Comment

by:searchsanjaysharma
ID: 37707440
ok, instead of script consider program
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 37707444
Ok...but if a secondary app unlocks the primary app by simply being run, what is keeping the user from directly running the secondary app?
0
 
LVL 40
ID: 37707781
If the users are connected full time, you could deploy the application through ClickOnce.

ClickOnce has an option to make the application available only online.

When the use starts the application, it gets installed temporarily on his computer if he is connected, otherwise he is told that he needs to be connected in order to use it.

When the application stops, it uninstalls automatically, but the Start menu icon that was created on the first installation stays there so that the user can restart the application.

This slows down the application when it starts because it needs to be reinstalled, but is if is a simple one, the process is not too long, not much longer than starting an Office application for instance.

Lookup ClickOnce in the documentation, on simply explore the Publish tab in the Project's properties window. For simple installation, just looking at the options in the Publish tab is self explanatory.
0
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 37723725
SelfDelete.zip
Note: since attachment doesn't allow *.asm and *.bin files, actual extensions for files in [asm] folder are SelefDel.asm (asm code) and SelfDel.bin (binary compiled asm file). Actually, demo doesn't use these files - mProcessInjection.bas module use opCode string constant - Hex dump of SelfDel.bin.
Methods I used in a demo:
1. Using batch file - app creates batch file which try delete main app in a loop - when main process completed, batch file successfully delete main app and then delete itself.
2. Using hidden console (cmd.exe) window - it run dos "del" command and wait it competition, then close itself.
3. DeleteOnClose - main app creates a shadow copy of its executable with InheritHandle = True, run it with command line, specifying main exe name and processID in command line. Shadow suspend main app process (WaitForSingleObject(hProcess, INFINITE)) and kill main app executable.
4. Using MFT records - not completed yet - just setting flag "InUse" in NTFS MasterFileTableRecord to false will hide file from OS.
5. Asm code injection - inject compiled asm code into running process namespace and call this code via CreateRemoteThread

As for recreation of deleted file - it's easy - just embed executable as a resource to a "restoration" program, read it when need and copy content into newly created file
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 37769538
ok
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now