Solved

Specifying a "start in" or working directory

Posted on 2006-03-27
3
210 Views
Last Modified: 2012-05-05
I am launching another program using the shell statement within a VB6 program, but I need to also specify the working directory.  For example, in a shortcut to a program, you can specify the "Start in" directory.  I need to specify this as a UNC path.  Is there any way to do this within a VB program?  This is what I have tried so far:

ChDir ("\\ServerName\Share")
Shell "\\ServerName\Share\Program.exe"


Thanks for the help!
0
Comment
Question by:bpl5000
[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
  • 2
3 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 16301803
Private Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long
Private Declare Function GetCurrentDirectory Lib "kernel32" Alias "GetCurrentDirectoryA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Private Sub Form_Load()
Dim cwd As String
Dim length As Long
SetCurrentDirectory "\\ServerName\Share"
cwd = Space(128)
length = GetCurrentDirectory(128, cwd)
cwd = Left(cwd, length)
MsgBox cwd
End Sub
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 500 total points
ID: 16301833
actually this should be all you need:

Private Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long

Private Sub Command1_Click()
SetCurrentDirectory "\\ServerName\Share"
Shell "\\ServerName\Share\Program.exe"
End Sub
0
 
LVL 5

Author Comment

by:bpl5000
ID: 16302240
That's perfect!  Thanks vinnyd!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

719 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