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
171 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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