Solved

Changing a path to a UNC path

Posted on 2007-03-20
9
252 Views
Last Modified: 2011-09-20
Hi all,

I have a text box in my app where the user can specify a datapath. However if they put in a mapped network drive I need something that will automatically change the contents of the text box to the full network path.
Can someone tell me how I can do this?

Thanks
0
Comment
Question by:kiranboi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18756086
Hmm - without knowing the server?

I wonder if you could redirect the output of a net use 'drive letter' to get at it...
0
 

Author Comment

by:kiranboi
ID: 18756143
sounds like it might work.
how do i do that tho?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18756171
Dim ps As New Process
Dim psi As New ProcessStartInfo
With psi
  .FileName="cmd"
  .Arguments="/c net use " & strDrive ' Perhaps use TextBox1.Text.SubString(0,2) for this
  .UseShellExecute=False
  .RedirectStandardOutput=True
  .WindowStyle=ProcessWindowStyle.Hidden
End With
With ps
  .StartInfo=psi
  .Start()
  .WaitForExit()
  .Close
End With
Dim strResults=ps.StandardOutput.ReadToEnd.Split(vbNewLine)
strPath=strResults(1) 'I 'think' it's the first element anyway...if that doesn't work, let me know...


0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 67

Expert Comment

by:sirbounty
ID: 18756188
Correction this line...since it's an array...

Dim strResults()=ps.StandardOutput.ReadToEnd.Split(vbNewLine)
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18756203
Looks like the first element (strResults(1)) will hold:

Remote name     \\server\share

So
TextBox2.Text=strResults(1).SubString(strResults(1).IndexOf("\"))

should do it...
0
 

Author Comment

by:kiranboi
ID: 18756814
Ive tried that and the line
   Dim strResults()=ps.StandardOutput.ReadToEnd.Split(vbNewLine)
is giving me the following error
   StandardOut not started or the process hasnt started yet

Any ideas?
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18756931
Slight modification - and this one's tested...

Dim ps As New Process
Dim psi As New ProcessStartInfo
With psi
  .FileName="cmd"
  .Arguments="/c net use " & strDrive 'strDrive must have the colon (F:)
  .UseShellExecute=False
  .RedirectStandardOutput=True
  .WindowStyle=ProcessWindowStyle.Hidden
End With
With ps
  .StartInfo=psi
  .Start()
  .WaitForExit()
End With
Dim strResults()=ps.StandardOutput.ReadToEnd.Split(vbNewLine)
TextBox2.Text=strResults(1).SubString(strResults(1).IndexOf("\"))
0
 

Author Comment

by:kiranboi
ID: 18772254
thats great thanx, thats exactly what i needed :)
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18772275
Happy to help - thanx for the grade! :^)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question