473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VB.net component process1 provide password

3
I'm trying to open MS Access application (open as independent application, I don't need to read date from it to my VB...) from my VB.net form and to provide MS Access the password.
I tried to use vb.net component process1 but I couldn’t write the password without vb.net errors.

The simple code I used:

Expand|Select|Wrap|Line Numbers
  1. Me.Process1.StartInfo.FileName = "c:\dummy.mdb"
  2. Me.Process1.StartInfo.Password = "1234" – (The error is: "Value of type string cannot be converted to system.security.securestring")
  3. Me.Process1.Start()
How can I solve it?
May 18 '10 #1
4 3573
balabaster
797 Expert 512MB
I don't mean to sound condescending here, but read and understand the error. "1234" is a string, and Me.Process1.StartInfo.Password is a SecureString.

I'm going to go out on a limb here and suggest looking in to System.Security.SecureString. I'll wager a significant amount that you need to be instantiating a secure string instead of a straight string

Beware this code example assumes that you have already got the string in memory. This is inherently insecure and should be avoided where possible. Given the assumption that you probably already have the string in memory, I'm not too concerned about the security implications of building the SecureString from the string. You really should instantiate it long hand though, passing each char in as the user types it so that the password doesn't exist anywhere in memory in a readable format:

Expand|Select|Wrap|Line Numbers
  1. Shared Process1 As New Process()
  2.  
  3. Private Shared Function CreateSecureString(ByVal str As String) As SecureString
  4.   Dim s = New SecureString()
  5.   Array.ForEach(Of Char)(str.ToCharArray(), Function(c) Do
  6.     s.AppendChar(c)
  7.   End Function)
  8.   Return s
  9. End Function
  10. Private Shared Sub Main(ByVal args As String())
  11.   Using s = CreateSecureString("1234")
  12.     Process1.StartInfo.FileName = "C:\Dummy.mdb"
  13.     Process1.StartInfo.Password = CreateSecureString("1234")
  14.     Process1.Start()
  15.   End Using
  16. End Sub
May 18 '10 #2
DrAvi
3
Hi,

Thank you for your answer my friend.
You are not being condescending; it is me being totally green with VB.net. I usually work with Access and VBA. VBA and VB.net are similar but different… I saw and understood the error msg, but didn’t know how to resolve it.

I've tried to use your suggestion, but there still is an error msg in this line:
Array.ForEach(Of Char) (str.ToCharArray(), Function(c) do s.AppendChar(c)End Function)

The "do" creates the error, suggesting that "expression expected".
Again, the solution may be simple, but I can't find my hands and legs here with the language differences….

Regards,
DrAvi
May 18 '10 #3
balabaster
797 Expert 512MB
@DrAvi
What version of .NET are you running? It probably has to do with the version you're using not supporting lambda expressions. Let me code it a different way to avoid that:

Expand|Select|Wrap|Line Numbers
  1. Private Shared Function CreateSecureString(ByVal str As String) As SecureString
  2.     Dim s = New SecureString
  3.     For Each c As Char In str
  4.         s.AppendChar(c)
  5.     Next
  6.     Return s
  7. End Function
May 18 '10 #4
DrAvi
3
The new code solved the previous error msg. now, new one came.. :)

The situation is this: The file I'm trying to open is MDB or Accdb, not EXE. When I'm trying to open MDB application with process1, without password, and without the above line codes, the MDB application gets open. from that I understand that process1 can hadle opening MDB applications.

When I'm adding the code above I'm getting errors. Using the code as it is returns the following error: "The Process object must have the UseShellExecute property set to false in order to start a process as a user"

Ok, so I added a line – Process1.StartInfo.UseShellExecute = False
But now, new error: "The specified executable is not a valid Win32 application"

Ok again, I added to the code the full path of access, changing the fileName line to:
Process1.StartInfo.FileName = "C:\Program Files\Microsoft Office\Office12\MSACCESS.EXE c:\dummy.mdb"
And now, surprise, new error: win32Exception was unhandled – wrong file name, directory name or syntax

My goodness… all I need is to open a simple MDB application
(Oh, I'm running the code on visual basic 2008 express edition)
May 18 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: elektrophyte | last post by:
I'm developing a webapp that needs to track users and provide each user with a view of their own data. In other words, it goes beyond merely protecting certain areas of the site. The application...
4
by: Neil Ginsberg | last post by:
I have ODBC linked tables to a SQL 7 database in an A2K database. The linked tables do not have the password stored in them, so the first time the user accesses them, they need to enter the SQL...
2
by: Jill Elaine | last post by:
I am building an Access 2002 frontend with linked tables to an encrypted Paradox 7 database. When I first create these linked tables, I'm asked for the password to the encrypted Paradox database,...
0
by: nht | last post by:
Hi, i have a problem. I try to create a non visual component. This is a simple component that makes database connection. I use the following code. But in design time i can't see the properties. I...
1
by: Dmitry Korolyov [MVP] | last post by:
Desired functionality: ability to upload files and save them into a database (or save them on the file system), ability to pick up files stored in the db or file system and send them in the reponse...
1
by: thoducng | last post by:
I am writing some code to access share folder on a remote network. DirectoryInfo dicInfo = new DirectoryInfo("remoteNetwork\shareFolder"); if (dicInfo.Exists) { //application code...
6
by: booner | last post by:
I have a business component I've built in its .vb file. Compiled the .vb file and copied the outputted dll to the bin directory of my virtual directory. Now in my aspx page when I attempt to...
1
by: mohanprasadgutta | last post by:
Hi, I need help to open a password protected excel file in perl using Win32:OLE. when I tried to open file in normal way at the time of program execution it is prompting me to enter password. I am...
3
by: shwethatj | last post by:
My problem is lik this , I am trying to create a PHP registration form for a HR website , but i dont know how provide password validation i.e the password and confirmation password entered by the...
1
by: shwethatj | last post by:
My problem is lik this , I am trying to create a registration form using javascript for a HR website , but i dont know how to provide password validation i.e the password and confirmation password...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.