Accessing Windows Security through Visual Basic - vba

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

Related

How to keep textbox data when copying a form to another computer?

I have a form with two textboxes and two buttons, I want the data in the two text boxes to be saved when the computer shuts down or when the form containing the two textboxes is copied to another computer.
Savedata1
Public Class Form1
Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click
My.Settings.SaveTitle = TextBox1.Text
My.Settings.SaveBody = TextBox2.Text
MsgBox("Saved textbox data")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = My.Settings.SaveTitle
TextBox2.Text = My.Settings.SaveBody
End Sub
Private Sub EndButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EndButton.Click
Me.Close()
End Sub
End Class
With the above code, I can only save data when the computer shuts down, but when copying the form to another computer the data in the textbox is not saved.
Can you show me how to keep textbox data when copying form to another computer?
Thank you for your help.
Are you wanting the data from the TextBoxes to be shared among all copies of the application? Like if you change the values on one computer, they update on the others?
Or, do you want the data to be persistent on an application copy instance? Like if I have a copy and change the values, the person I share the application with shares my values?
If you want the data to be consistent across all instances, use a webserver to store the values (either in a data store or as a simple XML file), and have each instance download the values on startup, or at regular intervals.
If the values are to be set by you, the developer, you could simply recompile the application with the new values and let the ClickOnce deployment system handle all the client updates for you.
If you want the values set on a copy per copy basis, you will have to include a file containing the values with the application, so each new user gets the application and the settings file as part of the package.

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

Can't get my datagridview to write back to MS Access database

I am using MS Access 2003 and vb.net to develop a windows application of inventory management.
I have used datagridview in the form and using FillBytoolstrip option, can filter data using type.
But i have no idea as to how can i update the database to reflect the latest changes in the gridview.
Tried searching but could not find proper and organised answer.
Could you please help me out with this ??
following is the code I have used. I am new to this. Please help !!
Private Sub BOM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.PartnoTableAdapter.Fill(Me.HemDatabase1DataSet3.partno)
End Sub
Private Sub FillByToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillByToolStripButton.Click
Try
Me.PartnoTableAdapter.FillBy(Me.HemDatabase1DataSet3.partno, TypeToolStripTextBox.Text)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
You have set up a TableAdapter PartnoTableAdapter to do the database reads (using Fill & FillBy methods).
Use the same TableAdapter to write back to the database using its Update method.

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