Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitlePrevent the user from renaming an executable in Visual Basic .NET
DescriptionThis example shows how to prevent the user from renaming an executable in Visual Basic .NET.
Keywordsrename, prevent rename, executable, execute, VB.NET
CategoriesSoftware Engineering, Miscellany
 
When the program starts, it gets the current process's name. It compares that name to the program's original name stored in code. If the names do not match, the example program gives the original and new names. A real application might refuse to run.
 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
    e As System.EventArgs) Handles MyBase.Load
    Const CORRECT_NAME As String = "howto_net_dont_rename"

    ' Get the current process name.
    Dim proc_name As String = _
        Process.GetCurrentProcess.ProcessName

    ' Compare to a hard-coded value.
    If proc_name = CORRECT_NAME Then
        lblStatus.Text = "Original name:" & _
            vbCrLf & CORRECT_NAME
        lblStatus.ForeColor = Color.Blue
    Else
        lblStatus.Text = "Renamed from:" & _
            vbCrLf & CORRECT_NAME & vbCrLf & _
            "To:" & vbCrLf & proc_name
        lblStatus.ForeColor = Color.Red
    End If
End Sub
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated