Results 1 to 5 of 5

Thread: Start program in "program files" folder

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    2

    Post

    Hi!

    I have to start a program in the "progam files" filer. How can I start a file called word.exe that is located in
    c:\program files\word.exe ??

    Thanx for helping me!

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    Shell "C:\Program Files\Word.exe"

    The path to the user's Program Files directory may change however. If you need to, the path is stored in the registry under HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\ProgramFilesPath

    Regards,

    ------------------
    - Chris
    [email protected]
    If it ain't broke - don't fix it

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Posts
    2

    Post

    Thanx for your answer but that won't help me. The thing is that program has to start a program that can be located anywhere on the harddrive. I get the path from the programs entry in the register but when the program is located in the "program files" folder I won't start using shell because shell is dos and doesn't understand the "program files" folder. If the program always was in "program files" I could set the path to "c:\progra~1\word" etc... I gave the wrong example so it's my falut. You answered the question right. What I really need is to start program using win32 and not dos.

    Thanx for helping me!

    / DaRkStAh!

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    To find the Program Files folder, try this:

    Code:
    Private Const CSIDL_PROGRAM_FILES = &H26
    Private Const MAX_PATH = 255
    Private Const SHGFP_TYPE_CURRENT = &H0
    Private Declare Function SHGetFolderPath Lib "shfolder.dll" Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, ByVal nFolder As Long, ByVal hToken As Long, ByVal dwReserved As Long, ByVal lpszPath As String) As Long
    
    Private Function GetProgramFolderPath(pHwnd As Long) As String
       Dim strPath As String
      
       strPath = Space$(MAX_PATH)
       If SHGetFolderPath(pHwnd, CSIDL_PROGRAM_FILES, 0&, SHGFP_TYPE_CURRENT, strPath) = 0 Then
           GetProgramFolderPath = Left$(strPath, InStr(strPath, vbNullChar) - 1)
       End If
    End Function
    Then use this function like this:


    Dim strProgFiles As String

    strProgFiles = GetProgramFolderPath(Me.Hwnd)


    strProgFiles now has the path to the program files folder.

    ------------------

    Serge

    Programmer Analyst
    [email protected]
    [email protected]
    ICQ#: 51055819


  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Shell isn't DOS, the problem you're having is that you have a Space in the Folder Name, enclose the Command to Shell in Quotes, ie.

    Call Shell(Chr(34) & sEXEtoShell & Chr(34), vbNormalFocus)

    Where sEXEtoShell is a String containing the Path and File Name of the Executable to Launch.

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width