Zdavander
asked on
Linking command buttons to an exe on a cd
I burned 6 software App on a CD, I'm always installing the same ones on clients systems so instead of swapping out 6 CD's one after the other. I got the idea to do the Autorun.inf file & the shell command to be able to allow right-click & chose which app to install, then i got cocky & wanted to do a little autorun exe "menu" which would have 6 command buttons each linked to the "folder\setup.exe" to launch the app. With the VB "menu" app on the CD what path do i tell the shell command to find the exe in a folder on the same cd. As the drive will not always be D: Or E: etc.
I don't even know what terms to use to google the question. The research has been fun though & think i may try to learn more.
I don't even know what terms to use to google the question. The research has been fun though & think i may try to learn more.
Just realized I didn't tie the code to the button. Let's try this again...
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Const STATUS_PENDING = &H103&
Private Const PROCESS_QUERY_INFORMATION = &H400
Private Sub Command1_Click()
ExecAndWait("notepad.exe")
end sub
Private Sub ExecAndWait(strApp)
Dim hProcessID&, hProcess&
Dim lngExitCode
hProcessID = Shell(strApp, vbNormalFocus)
hProcess = OpenProcess(PROCESS_QUERY_ INFORMATIO N, False, hProcessID)
' Disable all other buttons here
Form1.WindowState = 1
Do
Call GetExitCodeProcess(hProces s, lngExitCode)
DoEvents
Loop While lngExitCode = STATUS_PENDING
' Enable all other buttons here
Form1.WindowState = 0
End Sub
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Const STATUS_PENDING = &H103&
Private Const PROCESS_QUERY_INFORMATION = &H400
Private Sub Command1_Click()
ExecAndWait("notepad.exe")
end sub
Private Sub ExecAndWait(strApp)
Dim hProcessID&, hProcess&
Dim lngExitCode
hProcessID = Shell(strApp, vbNormalFocus)
hProcess = OpenProcess(PROCESS_QUERY_
' Disable all other buttons here
Form1.WindowState = 1
Do
Call GetExitCodeProcess(hProces
DoEvents
Loop While lngExitCode = STATUS_PENDING
' Enable all other buttons here
Form1.WindowState = 0
End Sub
ASKER
CleffedUp, Way over my head, i thought it would be;
Private Sub Command3_Click()
Shell ("*:\Rox5 \launch.exe")
End Sub
Where * is the CD drive, I've already made the GUI w/ the 6 command buttons in VB6, below is the autorun.inf file which loads the vb GUI menu i did, when the cd is inserted, then when i click command3 i want it to run the lanch.exe in the Rox5 folder on the CD & so on for the rest. Not sure what to even do w/ the code you wrote above, i was thinking this was a one line of code for each button kind of thing. If i'm just not getting at this from the right angle let me know
[AutoRun]
Open=Menu.exe
Shell\NAV2003=NAV2003
Shell\NAV2003\Command=NAV\ setup.exe
Shell\Roxio5=Roxio5
Shell\Roxio5\Command=Rox5\ launch.exe
Shell\InterVideo=InterVide o
Shell\InterVideo\Command=I nter\setup .exe
Shell\WinDVD=WinDVD
Shell\WinDVD\Command=Windv d\setup.ex e
Shell\Acrobat=Acrobat
Shell\Acrobat\Command=ar50 5enu.exe
Shell\NAV2002=NAV2002
Shell\NAV2002\Command=NAV2 \setup.exe
Private Sub Command3_Click()
Shell ("*:\Rox5 \launch.exe")
End Sub
Where * is the CD drive, I've already made the GUI w/ the 6 command buttons in VB6, below is the autorun.inf file which loads the vb GUI menu i did, when the cd is inserted, then when i click command3 i want it to run the lanch.exe in the Rox5 folder on the CD & so on for the rest. Not sure what to even do w/ the code you wrote above, i was thinking this was a one line of code for each button kind of thing. If i'm just not getting at this from the right angle let me know
[AutoRun]
Open=Menu.exe
Shell\NAV2003=NAV2003
Shell\NAV2003\Command=NAV\
Shell\Roxio5=Roxio5
Shell\Roxio5\Command=Rox5\
Shell\InterVideo=InterVide
Shell\InterVideo\Command=I
Shell\WinDVD=WinDVD
Shell\WinDVD\Command=Windv
Shell\Acrobat=Acrobat
Shell\Acrobat\Command=ar50
Shell\NAV2002=NAV2002
Shell\NAV2002\Command=NAV2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh, I did not know about that (to much infomation can be dangerous), i thought the running app would take over... but the focus back to the menu when done is perfect i really like that.
As other posts say "i'm a newbie" I AM NOT even a newbie, I messed around w/ basic back in '84-'86, made a duck hunt game, and a lot of "if then goto" stuff.
I'll put it together, thanks for the help.
As other posts say "i'm a newbie" I AM NOT even a newbie, I messed around w/ basic back in '84-'86, made a duck hunt game, and a lot of "if then goto" stuff.
I'll put it together, thanks for the help.
No problem, glad to help. Happy installing!
ASKER
I'm getting a snag w/ the path run time 53 file not found w/ Shell ("\folder\app.exe"), if I code for the root, shell("app.exe") & empty the folder onto the CD the app comes back w/ an install error, which it does not do if I right-click the drive & install w/ the
Shell\app=app
Shell\app\Command=folder\a pp.exe
in autorun.inf
Shell\app=app
Shell\app\Command=folder\a
in autorun.inf
ASKER
Forget it I got it.
When I try & use the code you 1st wrote, I'm sure I'll be back.
Again thanks.
When I try & use the code you 1st wrote, I'm sure I'll be back.
Again thanks.
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Const STATUS_PENDING = &H103&
Private Const PROCESS_QUERY_INFORMATION = &H400
Private Sub Form_Load()
Dim hProcessID&, hProcess&
Dim lngExitCode
hProcessID = Shell("notepad.exe", vbNormalFocus)
hProcess = OpenProcess(PROCESS_QUERY_
Form1.WindowState = 1
Do
Call GetExitCodeProcess(hProces
DoEvents
Loop While lngExitCode = STATUS_PENDING
Form1.WindowState = 0
End Sub