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
174 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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 28

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Gridview selected row 9 50
Assigning handler to UserControls in flowlayoutpanel 4 28
VB.NET - Error - Object not set in Module 4 41
RLDC Reporting in Visual studio 11 31
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 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