Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
1.50/5 (4 votes)
See more:
I want to know how can I disable an .exe file using vb6 :)
Thanks in advance...
Posted
Updated 12-Apr-11 6:07am
v2
Comments
Dylan Morley 12-Apr-11 4:28am    
What do you mean, disable an exe? Stop the code from being able to execute? Or detect when it's running and stop it?

Need. Moar. Info.
kikoman_62 12-Apr-11 5:12am    
what i mean is, i want to prevent a .exe file to be execute with the use of vb6 codes..
Sergey Alexandrovich Kryukov 12-Apr-11 11:58am    
Why?! makes no sense...
--SA

To prevent users from executing the program you could consider adjusting the access rights to the executable:
How to use high-level access control APIs from Visual Basic
[^]

This will effectively "disable" the executable for unauthorized use :)

For more information on the windows authorization apis' take a look at:
Authorization[^]

Regards
Espen Harlinn
 
Share this answer
 
The question and what you possibly may want makes no sense at all.
Don't create EXE file!

You don't explain the use of this executable.
If your purpose is to prevent accidental run of this file, one simple trick is: rename its extension part. The file still can be loaded run as application via a call to CreateProcessEx explicitly (file name does not really mean anything special as well as its "extension" part) but it won't be accidentally run on click by the Shell.

—SA
 
Share this answer
 
You could do something like this:


  1. Encrypt the original exe
  2. Have a stub exe in VB6 that prompts for a password
  3. If the password is correct, decrypt the original exe and run it
  4. If the password is wrong, show an error and exit
  5. You can also have a version of the stub executable that uses windows auth to run the executable (and you can have a pre-decided list of allowed users)
 
Share this answer
 
Applicable: VB6 & VB6 Created Exe files

This a Not a robust trick: Some Anti-Virus programs won't allow this and they will detect the scrambled exe file as virus

PUBLIC FUNCTION ScrambleVbExe(Fname as string, DoIt as boolean)

Dim sBuffer As String
Dim FN As Integer
FN = FreeFile

Open Fname For Binary As #FN
sBuffer = Space$(LOF(FN))
Get #FN, 1, sBuffer
Close #FN

if DoIt=true then
sBuffer = Replace(sBuffer, "MSVBVM60.DLL", "PREVENTMYRUN")
else
sBuffer = Replace(sBuffer,  "PREVENTMYRUN", "MSVBVM60.DLL")
end if

Open Fname For Binary As #FN
Put #FN, , sBuffer
Close #FN

End function
 
Share this answer
 
v4
If you want to prevent the executable from being started, just open it and write a character in the file.
 
Share this answer
 
Comments
kikoman_62 12-Apr-11 5:36am    
what i mean is, i want to prevent a .exe file to be execute with the use of vb6 codes..
Eduard Keilholz 12-Apr-11 5:38am    
If you change the file, it will not execute...
kikoman_62 12-Apr-11 5:43am    
with out changing the name of the file. like example when i press the commandbutton all .exe file will not be executed. something like that.
Eduard Keilholz 12-Apr-11 5:53am    
What I meant, is that you open the file for editing, and change it's content, not the filename

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900