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

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

Related

Access database connecting to VS but no data showing and runtime error

Trying to use an access database with Visual studio 15. After failure I found a number of tutorials and followed them with a new project and new database.
The database is connecting but the data inside the database won't display (although no error) and even using the built in save function in VB results in a run time error.
If anyone can point me in the right direction I'd be grateful. Code below.
Public Class Form1
Private Sub CustomersBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles CustomersBindingNavigatorSaveItem.Click
Me.Validate()
Me.CustomersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.CustomersDataSet) 'Error is here****
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'CustomersDataSet.Customers' table. You can move, or remove it, as needed.
Me.CustomersTableAdapter.Fill(Me.CustomersDataSet.Customers)
End Sub
Private Sub BindingNavigatorDeleteItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorDeleteItem.Click
End Sub
Private Sub BindingNavigatorAddNewItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorAddNewItem.Click
End Sub
End Class
The error message I get is An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll
Additional information: Unspecified error.
Here is a video that I made a while ago that should be able to help you, If you have any questions about it, i can definitely help you out.
https://www.youtube.com/watch?v=vvzY0LsAUNE
Also do you definitely need to use Access? I would recommend using an SQL database because when you publish your program, the end user may have to have a link to your access database in the same spot as yours, which can be a pain.
Nevertheless here is a video i also made regarding setting up an SQL database via Visual Studio.
https://www.youtube.com/watch?v=NLs44hxV514
If you have any issue, leave a comment and i will be happy to help you out :)
Keep In Mind
Don't forget that you need to also have a Number/unique word/or something a like in the Primary key column even if you haven't added any details to the database. eg Name and so on. If not your program may crash, so you could use the Try statement to fix this issue if the Primary Key column is left empty.

How do you launch an .exe in a VB.net application who's directory varies amongst users?

I am creating an application for an Arma 3 server that directly launches the game and connects the user to a specific server. The problem that I am encountering, being the relatively new VB coder that I am, is that the Arma3battleye.exe directory (the .exe used to launch the game) may be installed in different directories depending on where the user originally installed it. I've developed the code to connect the user to the server if they've installed Arma in the normal location:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Process.Start("C:\Program Files (x86)\Steam\steamapps\common\Arma 3\arma3battleye.exe", "2 1 -noSplash -skipIntro -useBE -noPause -world=empty -connect=192.99.36.80 -port=2505 -mod=#Exile;#AlRayak;#AllInArmaTerrainPack;#CUP Units;#CUP Vehicles;#CUP Weapons;#CBA_A3;#TRYK's Multi-Play Unifrom's pack")
End Sub
However, after researching for many hours, I cannot determine how to have the program automatically determine the install directory of the arma3batteye.exe and then execute it with all of the correct start parameters included. Any solutions or pointers to help solve this problem would be greatly appreciate.
TLDR: What is the easiest way to program an application to automatically find the install directory of a given .exe and then execute it with the given parameters as I've done above?
Edit: Another thread similar to mine asks a similar question (how to view/get to the steam folder without hard coding it. They arrive at the conclusion that if you do (for winx32):
Dim strSteamInstallPath as String = My.Computer.Registry.GetValue(
"HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath", Nothing)
Or using this registry location for winx64:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam
and then were to create a button using Process.Start that it would allow you to ultimately view the directory. At this point I haven't discovered a way for that to translate into being able to execute the battleyearma3.exe from within that steam directory with the proper parameters. While it seems this code may be useful in arriving at the solution I'm looking for, I can only get the program to view the general steam directory at this time.
edit: Solution posted at bottom. Thanks to #VisualVincent who was really the one that allowed me to complete this. It really should be you having posted the correct answer, not me.
I would use the registry...
You add a key like HKEY_LOCAL_MACHINE\Software\Arma3\ServerPath = "..." when you install the server.
And whenever you need to start the client, you check up the path from that registry key.
So with the comments and tips you gave me (especially #VisualVincent) I managed to piece enough stuff together to solve my issue. Thanks to everyone for the help:
First I declared 2 variables. The first one (BattleyePath) goes into the registry as far as I can get it to dig. Executing this variable on its own will open the users steam directory. I then declared a second variable (BattleyePath2) which uses IO.Path.Combine get to the directory the users Arma3.exe is installed in:
Dim BattleyePath As String = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam", "InstallPath", Nothing)
Dim BattleyePath2 As String = IO.Path.Combine(BattleyePath, "SteamApps", "common", "Arma 3", "arma3battleye.exe")
I added a couple buttons to close the program and mute the sound:
`Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
My.Computer.Audio.Stop()
End Sub`
Finally I created the button that actually launches the game:
`Private Sub Button4_Click_1(sender As Object, e As EventArgs) Handles Button4.Click
Process.Start(BattleyePath2, "2 1 -noSplash -skipIntro -useBE -noPause -world=empty -connect=192.99.36.80 -port=2505 -mod=#Exile;#AlRayak;#AllInArmaTerrainPack;#CUP Units;#CUP Vehicles;#CUP Weapons;#CBA_A3;#TRYK's Multi-Play Unifrom's pack")
End Sub`

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

Getting a stack overflow exception when calling OpenFileDialog1.ShowDialog() [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Attempted to read or write protected memory. When I call showDialog method of openfileDialog
Not sure why. It was originally working just fine, then I made some changes to the code that should have had no effect on this.
The changes I made where to just change some properties of a checkbox when the file is selected:
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs)
attachmentLabel.Text = OpenFileDialog1.FileName.ToString()
attachmentCheckBox.Visible = True
attachmentCheckBox.Checked = True
End Sub
Here's the event handler that calls OpenFileDialog1.ShowDialog()
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
OpenFileDialog1.Title = "Please Select a File"
OpenFileDialog1.InitialDirectory = "C:temp"
OpenFileDialog1.ShowDialog()
End Sub
Any help would be appreciated.
When the exception occurs, the values for e and sender say "unable to evaluate expression".
(This is really a comment, but it is too big.)
It is due to:
some of your code not shown here,
some filesystem or networking issue specific to your machine, or
a transient problem with VisualStudio (or the VB.NET compiler).
To rule out (3), (and (2) if the problem is transient) reboot your machine and rebuild your application (either clean and then build or at least just rebuild).
To confirm (2), try running your program on a different machine.
To help locate the issue if it is (1), search your code for references to OpenFileDialog1. If it appears anywhere other than in designer generated code and the two events you have shown in your question, include them in your question.
If the problem does still occur, confirm if it occurs with both Debug and Release builds or not, and include the designer generated code in the question as well.

Application to Startup::: Access Error

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