Application to Startup::: Access Error - vb.net

Hi
I am using following code to add my application to StartUp of Windows. It works well in XP but gives error in Vista that you donot have permission to edit registty file.
Private Sub Forceps_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Dim regStartUp As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
'Dim value As String
'value = regStartUp.GetValue("Myapp")
'If value <> Application.ExecutablePath.ToString() Then
'regStartUp.CreateSubKey("Myapp")
'regStartUp.SetValue("Myapp", Application.ExecutablePath.ToString())
' End If
End Sub

This is caused by the User Account Control (UAC) feature in Vista. Admininstrators on Vista (and 7 and Server 2008 sometimes) run with a user token that is limited in privileges unless the application explicitly requests them.
Some links to read about UAC and how to configure your application.
http://en.wikipedia.org/wiki/User_Account_Control
http://technet.microsoft.com/en-us/library/cc709691(WS.10).aspx
http://bartdesmet.net/blogs/bart/archive/2006/10/28/Windows-Vista-2D00-Demand-UAC-elevation-for-an-application-by-adding-a-manifest-using-mt.exe.aspx

Related

Validating License Key on separate form?

I have an application which has a license key function.
The user gets their license key, then type it into the TextBox where the license key is supposed to go, and if the license key is valid, they get taken to the main form, where all of the features are.
Now, to make my program more secure, I need to be able to check that the user has definitely typed in their license key, and they haven't done something like delete (by decompiling) the license key form so they can gain access to the main form where all of the features are.
Note: My license keys are stored on a server.
How would I check that the user has definitely typed in the license key?
Below is the code.
AddLicense.vb:
Imports SKM.V3
Imports SKM.V3.Models
Imports SKM.V3.Methods
Public Class AddLicense
Private p_oRandom As Random
Private Const INTERVAL_MIN_SEC As Integer = 4
Private Const INTERVAL_MAX_SEC As Integer = 25
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If BunifuProgressBar1.Value = 50 Then
Label3.Show()
Label2.Hide()
End If
BunifuProgressBar1.Value += 1
If BunifuProgressBar1.Value = BunifuProgressBar1.MaximumValue Then
BunifuProgressBar1.Hide()
Label3.Hide()
Label2.Hide()
Timer1.Stop()
BunifuMaterialTextbox1.Show()
BunifuThinButton21.Show()
Label4.Show()
LinkLabel1.Show()
BunifuThinButton22.Show()
End If
Timer1.Interval = p_oRandom.Next(INTERVAL_MIN_SEC, INTERVAL_MAX_SEC) * 3
End Sub
Private Sub BunifuImageButton1_Click(sender As Object, e As EventArgs) Handles BunifuImageButton1.Click
Me.Close()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
p_oRandom = New Random
End Sub
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Try
Process.Start("https://selly.gg")
Catch ex As Exception
End Try
End Sub
Sub Nolicense()
BunifuThinButton21.Enabled = False
End Sub
Private Sub BunifuThinButton21_Click_1(sender As Object, e As EventArgs) Handles BunifuThinButton21.Click
Dim token = "WyIxMDM2IiwiZ082d2dnS0FmTkRuTXNPcGhlSkllVEx6ckFWMFhhSzlMM3Rvc01xUSJd"
Dim key = BunifuMaterialTextbox1.Text.Replace(" ", "")
Dim license = New LicenseKey() With
{
.ProductId = 3888,
.Key = key
}
If license.Refresh(token, True) Then
' we are able to auto complete missing key info
Me.BunifuThinButton21.Enabled = license.HasFeature(1).IsValid() ' either we have feature1 or not.
MsgBox("License is valid! Thanks for purchasing.")
Me.Hide()
Sploitbase.Show()
If license.HasFeature(4).HasNotExpired().IsValid() Then
Me.Hide()
Sploitbase.Show()
ElseIf license.HasNotFeature(4).IsValid() Then
Else
MsgBox("Your license has expired and cannot be used.")
Nolicense()
End If
license.SaveToFile()
Else
' something went wrong.
MsgBox("Unable to access the license server or the key is wrong.")
End If
Me.Close()
End Sub
Private Sub BunifuThinButton22_Click(sender As Object, e As EventArgs) Handles BunifuThinButton22.Click
End Sub
End Class
Sploitbase.vb - the main form:
Imports SKM.V3
Public Class Sploitbase
Private Sub Sploitbase_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Public Sub NoLicense()
End Sub
Private Sub TabPage1_Click(sender As Object, e As EventArgs)
End Sub
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs)
Try
Process.Start("https://selly.gg")
Catch ex As Exception
End Try
End Sub
End Class
I believe what you want is to stop users from decompiling your program and removing the license key form entirely...
Unfortunately, it's impossible to stop that, as long as a program can be run on an ordinary computer, it can be decompiled, otherwise, it would be impossible for the processor to process it.
This means, that it would be possible to remove the relevant instructions for that, and C# and VB is easy to decompile - tools like dotPeek get valid source code (it won't be exactly the same as the original, but still readable and runs like the original) just with a click.
Keep in mind that even proper commercial programs made by whole companies have this problem.
So, what could you possibly "do"? Well, I only really have two suggestions... but they won't work too well.
One only makes it harder and the other one requires access to the internet all the time.
Obfuscation
Obfuscation essentially makes the code harder to read after decompiling, however, it won't stop people from deleting the form, it will just make it slightly harder.
I posted it as an option because it will make the code very confusing when recompiling and it might be helpful to "protect" it a bit more. However, just remember this: "It's a weak layer of defence for a weak attacker."
An obfuscator you could use is Eazfuscator.NET, that webpage I sent also has a description of essentially what it does and how to use it - it may be worth taking a look at.
Online Servers
This one requires a connection to the internet... but, it's the only other option you have at all - it's either this or... able-to-get-rid-of-product-key.
Essentially, in this idea, you make a server do all the work that the application has to do and then return the result of it.
Imagine the user's computer is a server. Their "server" runs the code, and so the code is on their "server" (otherwise it has nothing to run) and everything is processed on their server. Now, if you run it on your server, all the code is on your server and your server only returns the result, meaning, they can't get at the process that provides that result.
In the end, this would mean that the application physically would not be able to do anything without a license key, since the only way it can get its data processed is via the server, and the server won't process the data without a product key.
The only downside to this is that you must have an internet connection and if the internet connection is slow - the program will be slow.
Since you want to know how to do this in vb.net taking a look at ASP.NET may help, but it's really designed to make a full-website - not to just process a few tasks.
I can leave it up to you how you would want to approach this task but here's one way of doing this:
The code below will make a "request" to a certain URL and then get the result back - with this, you could make it so when it goes to that URL the server processes the data given (including the product key) and returns back a result.
Dim request As System.Net.HttpWebRequest
Dim response As System.Net.HttpWebResponse
request = System.Net.HttpWebRequest.Create("https://URLHERE")
response = askforupdate.GetResponse
Dim result As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream)
result now contains a String - but, keep in mind that you can use this for practically anything - even images! (Images are just New Bitmap(response.GetResponseStream))
You can pass data to the server via a Query String, for example:
my.website/processSomething?license=AAAAAAAA&sizeInput=241&somethingElse=asagsag
But, really, it's up to you how you do that.
I'm sorry I couldn't give you an exact solution, but, there really isn't one. You're going to end up sacrificing something either way.
Hopefully, this was at least helpful and helped you understand that it's really not possible to prevent people hacking your software without losing something.

How i can run html file iwith vb in visual studio 2008

I tried to run with Process.Start(path of file.html)
Private Sub TestΜαθηματικάIΙIToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TestΜαθηματικάIΙIToolStripMenuItem.Click
Process.Start("C:\Mathimatika\3o_test_M-III\test.html")
End Sub
but i have this error "The system cannot find the file specified" I'm sure 100% path is correct.
Can anyone suggest me some other way?
thanks in advance
You can get this message if something else prevents your process from opening the file, such as if it does not have permissions to access the file, or if the file is locked by another process.
Also, if you're trying to do this from an ASP.Net web site, remember that your code is running on a web server that will not have access to the file system on computer hosting the web browser.
Looking again: it's just not escaping the \ character in the file path. All you need to do is add a # so that you get an unescaped string:
Private Sub TestΜαθηματικάIΙIToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TestΜαθηματικάIΙIToolStripMenuItem.Click
Process.Start(#"C:\Mathimatika\3o_test_M-III\test.html")
End Sub

VB.NET/Access DataGridView not displaying table contents

I'm attempting to display an Access Database table in a DataGridView on the most simple form you could make. However, when I start the application I don't see any of the table data. See below.
I'm happy to update with any additional information needed.
VB:
Option Explicit On
Option Strict On
Option Infer Off
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'MOKANDataSet.SalaryHistory' table. You can move, or remove it, as needed.
Me.SalaryHistoryTableAdapter.Fill(Me.MOKANDataSet.SalaryHistory)
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
Here is the application at runtime.
Overview of project in Visual Studio
I was curious and went directly to the executable in the bin folder. Upon execution, I got "The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine. I'm using Win 7 64 Bit, but the Microsoft Office suite I have is 32-bit. I got the 32-bit AccessDatabase Engine referenced here

Accessing Windows Security through Visual Basic

I've created a code that copies the folder contents from PC1(pc for user) to PC2(pc for server). I used Active Directory to create accounts for the access of PC2's server
I have the ff code to transfer from PC1 to PC2:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
My.Computer.FileSystem.CopyDirectory("C:\Users\Bounty Hounds\Desktop\1", "\\WIN-2I9JBRPFMO7\UserFiles\joshua824\Desktop\joshua824", True)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
My.Computer.FileSystem.CopyDirectory("\\WIN-2I9JBRPFMO7\UserFiles\joshua824\Desktop\joshua824", "C:\Users\Bounty Hounds\Desktop\1", True)
End Sub
End Class
This only works if you pass the server's login information that only seems to show when I try to manually enter the address of the server
I found two ways to approach this problem
First
Create a login form
Second form would tell Windows Security via vb code that my username and password are what I inputted on the login form
Second
Create a code that will show Windows Security automatically when running my visual basic program
However i'm struggling on how do I tell Windows Security about my login info and at the same time I don't know how do I manually show Windows Security

creating text file in wp7 using vb.net

I have tried following code:
imports system.io
imports system.io.isolatedstorage
private sub Button_Click(sender as system.object, e as system.windows.routedeventargs) handles button1.click
dim isoStore As IsolatedStorageFile = isolatedstoragefile.getuserstoreforapplication
isostore.createfile("c:\test.txt")
end sub
when i run the code on windows phone emulator it shows exception "Operation not permitted on isolatedstoragefilestream"
Windows Phone is not like a PC operating system, there is no C:\ - each app has it's own contained area where you store and access files, hence the name IsolatedStorage.
GeekChamp has a great tutorial on IsolatedStorage, which is in C#.
For VB.Net, the following code sample should help you getting started with IsolatedStorage:
http://code.msdn.microsoft.com/wpapps/VBWP8ImageFromIsolatedStora-11071695