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!
Printable View
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!
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 :)
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!
To find the Program Files folder, try this:
Then use this function like 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
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
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]