Solved

Password protect uninstallation of application

Posted on 2004-10-25
352 Views
Last Modified: 2008-10-26
Hi All,

This is a tough one. I'd give more points if I could.

I want the Uninstaller (not VB's uninstaller) to prompt for a password (password would be the Admin password of the application itself, which is setup the first time my app is run, stored and encrypted in the registry), prior to performing the uninstallation.

Anyhow, I've used Inno Setup to create my setup file. If anyone is familiar with this setup utility, and could assist me here, I would be forever grateful.

I imagine it would take some tweaking of the compiled Uninstallation .dat file....quite the difficult task.

Thx!
0
Question by:knuckle05
    4 Comments
     
    LVL 48

    Expert Comment

    by:Ryan Chong
    You can't, as the files installed on your machine can be deleted physically if you want to delete it manually. You can't prevent a user to delete your installed files, UNLESS you set the permission so that your logon user cannot delete the application files you had installed.
    0
     
    LVL 28

    Accepted Solution

    by:
    As ryancys said,what is to prevent the user from deleting the files? If you still want to password the uninstall here is an idea that will work.

    The concept here is to create a seperate password app and write the Inno unistall file onto the end of it. Then when Inno unistall is run,your app will run where you can verify password.If the password is correct, read the inno unistall file data out of the password app and launch. If you want to try this add this routine to your main app to be run after install:

    ' command button shown for example,you would only want to call this
    ' routine once after installation
    Private Sub Command1_Click()
    WeldUninstallFile "unins000.exe", "Passwd.exe"
    End Sub

    Private Sub WeldUninstallFile(InnoUninstFile As String, PasswdApp As String)
    Dim uFileData As String
    Dim Pntr As Long, ff As Integer

    ' open inno uninstall file and read into uFileData
    ff = FreeFile
    Open InnoUninstFile For Binary Access Read As #ff
    uFileData = Space(LOF(ff))
    Get #ff, , uFileData
    Close #ff

    ' write uFileData to the back of the password app
    ff = FreeFile
    Open PasswdApp For Binary Access Write As #ff
    Pntr = LOF(ff) + 1
    Put #ff, Pntr, Chr$(0) & "<--->" & uFileData ' <---> used as a delimiter
    Close #ff

    ' kill the original inno unistall.exe
    Kill InnoUninstFile

    ' rename password app as inno unistall file
    Name PasswdApp As InnoUninstFile

    End Sub



    Then create a seperate exe to be installed with inno.Compile it and call it passwd.exe


    ' add 1 textbox called txtPasswd and a command button called cmdOk.
    ' Compile into Passwd.exe and install to the same directory as your app.

    Private Sub cmdOk_Click()
    ' simple password validation example,replace with your code
    ' to read from registry
    If txtPasswd = "MYPASSWORD" Then
        SpitOutUninstallFile "Uninstall.exe"
    End If
    End Sub


    Private Sub SpitOutUninstallFile(OutputFileName As String)
    Dim uFileData As String, mFile As String, arrDat() As String
    Dim InnoDat As String, NewDat As String, ff As Integer

    If Right$(App.Path, 1) <> "\" Then
        mFile = App.Path & "\" & App.EXEName & ".exe"
        InnoDat = App.Path & "\unins000.dat"
    Else
        mFile = App.Path & App.EXEName & ".exe"
        InnoDat = App.Path & "unins000.dat"
    End If

    ' Open This exe file and read binary data into uFileData
    ff = FreeFile
    Open mFile For Binary Access Read As #ff
    uFileData = Space(LOF(ff))
    Get #ff, , uFileData
    Close #ff

    ' split file data to get Uninstall file out
    arrDat = Split(uFileData, "<--->")

    ' create new Uninstall File
    ff = FreeFile
    Open OutputFileName For Binary Access Write As #ff
    Put #ff, , arrDat(1)
    Close #ff

    ' get name for new dat file,it must match inno's uninst name w/ .dat ext
    NewDat = Left$(OutputFileName, InStrRev(OutputFileName, ".") - 1) & ".dat"

    ' rename inno dat to new dat name
    Name InnoDat As NewDat

    ' call the extracted Uninstall file
    Shell OutputFileName, vbNormalFocus

    End Sub


    0
     
    LVL 1

    Author Comment

    by:knuckle05
    Hey vinnyd79,

    Thanks for this suggestion, I will try it out ASAP and report back here.

    I understand that someone could just delete the physical files from the drive, the thing is, there are some other "monitor type" services installed with my program that aren't easily detectable as I install them in the system folder.

    The application I wrote is a web browser for kids, and included with it is a monitoring service that blocks the use of IE  and / or other mainstream browsers.

    With a password protected uninstall file, this will at least preserve these monitors that run at startup. Not to say that they still couldn't be bypassed, I mean, they do show up as a running process in the task manager....anyhow, thx for your help, and I'll post back soon!
    0
     
    LVL 1

    Author Comment

    by:knuckle05
    vinnyd79,

    Pure genius!

    It works mint, I had to make a few small additions, specifically some error handling in case I cancelled the process (as it would leave files behind) but it works great!

    Question: It seems fairly simple to just weld the 2 together, but how come appending the original Inno setup file to the back of my PW app did not cause the EXE to crash? I was really surprised that it worked...

    I'm really curious as to how you came up with this solution...pls give me some insight.

    Thx!
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    913 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

    17 Experts available now in Live!

    Get 1:1 Help Now