1. Is it possible to grab command line parameters. For instance if my prog is run like this : myprog.exe /uninstall
2. How do I delete the exe the current program is running from. Like uninstall deletes itself?
Printable View
1. Is it possible to grab command line parameters. For instance if my prog is run like this : myprog.exe /uninstall
2. How do I delete the exe the current program is running from. Like uninstall deletes itself?
1. see help on the "Command" function
2. does "Kill" statement not work?
Q1:
Use the Command function.
Q2:Code:Private Sub Form_Load()
Select Case Command
Case "/a"
MsgBox "Paramater = /a"
Case "/b"
MsgBox "Paramater = /b"
Case Else
MsgBox "Usage:" & vbCrLf & "/a - a" & vbCrLf & "/b - b"
End Select
End Sub
There is no way a file can delete itself while it's running. But what you can do is create a second file. Bat files can delete themselves so you can use a bat file which will delete the program and then delete itself.
Parameters = Command$
I'm not sure if even uninstall apps delete themselves, maybe you have to put something in win.ini that deletes your file at startup
I had the same prob week ago:
make a batch file,and the batch file even delete itself
batch file :
in vb:Code:del %1
cd..
rd %2
cd\
del %3
It delete the uninstall, the folder that use to contain theCode:Shell "c:\delete.bat " & "your_uninstall.exe " & "yourfolder " & "c:\delete.bat", vbHide
uninstall and then delete the batch file.
Be sure to put the code in the form_terminate().
Let me know if you have trouble with this !!
Thanks for command statement (couldn't remember it)
I don't think they delete themselves.
Win.ini is a bit outdated. Isn't there a registry function these days?
Never used it before so you'll have to explain
(Never programmed win 3.1)
look at my previous thread
Thanks guys!
Batch file good enough