Tyraenor Posted July 8, 2008 Share Posted July 8, 2008 Hey ppl, I have a weird problem with running an external app (Adobe Reader). I search with the "dir" command (dir /b /s /a) for the Adobe Reader and want to use the path to run the application. See my code for details... expandcollapse popup... While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $sourceBtn If GUICtrlRead($srcFileTypePDF) = $GUI_CHECKED Then $_theFile = FileOpenDialog("Please select the source file", @ScriptDir, "PDF files (*.pdf)") $AdobePath = isAdobe() If $AdobePath <> False Then; Check if Adobe Reader is installed Run($AdobePath, @SystemDir) <---- This does _NOT_ work ($AdobePath contains: C:\Programme\Adobe\Reader 8.0\Reader\AcroRd32.exe) Run("C:\Programme\Adobe\Reader 8.0\Reader\AcroRd32.exe", @SystemDir) <---- This works fine Else MsgBox(48, "Error", "Adobe Reader cannot be found!") EndIf ElseIf GUICtrlRead($srcFileTypeTxt) = $GUI_CHECKED Then $_theFile = FileOpenDialog("Please select the source file", @ScriptDir, "Textfiles (*.txt)") EndIf Case $srcFileTypePDF; If the user clicks on "Source is orig. PDF", inform him that Adobe Reader is required If GUICtrlRead($srcFileTypePDF) = $GUI_CHECKED Then MsgBox(64, "Info", "Note: To use the original PDF as source, Adobe Reader has to be installed on your system!") EndSwitch WEnd Func isAdobe() RunWait(@ComSpec & " /c dir /b /s /a AcroRd32.exe > " & @TempDir & "\_tmpFindAcroRd.txt", @ProgramFilesDir & "\Adobe", @SW_HIDE) If StringInStr(FileRead(@TempDir & "\_tmpFindAcroRd.txt"), "AcroRd32.exe") Then Return FileRead(@TempDir & "\_tmpFindAcroRd.txt") Else Return False EndIf FileDelete(@TempDir & "\_tmpFindAcroRd.txt") EndFunc So when I use the Run command to execute the program, nothing happens. Not even an error message!! I have no idea anymore... Maybe I am too blind to see the error. muttley I hope someone here can help me! Cheers Ty Link to comment Share on other sites More sharing options...
Monamo Posted July 8, 2008 Share Posted July 8, 2008 (edited) Hey ppl, I have a weird problem with running an external app (Adobe Reader). I search with the "dir" command (dir /b /s /a) for the Adobe Reader and want to use the path to run the application. See my code for details... CODE... While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $sourceBtn If GUICtrlRead($srcFileTypePDF) = $GUI_CHECKED Then $_theFile = FileOpenDialog("Please select the source file", @ScriptDir, "PDF files (*.pdf)") $AdobePath = isAdobe() If $AdobePath <> False Then; Check if Adobe Reader is installed Run($AdobePath, @SystemDir) <---- This does _NOT_ work ($AdobePath contains: C:\Programme\Adobe\Reader 8.0\Reader\AcroRd32.exe) Run("C:\Programme\Adobe\Reader 8.0\Reader\AcroRd32.exe", @SystemDir) <---- This works fine Else MsgBox(48, "Error", "Adobe Reader cannot be found!") EndIf ElseIf GUICtrlRead($srcFileTypeTxt) = $GUI_CHECKED Then $_theFile = FileOpenDialog("Please select the source file", @ScriptDir, "Textfiles (*.txt)") EndIf Case $srcFileTypePDF; If the user clicks on "Source is orig. PDF", inform him that Adobe Reader is required If GUICtrlRead($srcFileTypePDF) = $GUI_CHECKED Then MsgBox(64, "Info", "Note: To use the original PDF as source, Adobe Reader has to be installed on your system!") EndSwitch WEnd Func isAdobe() RunWait(@ComSpec & " /c dir /b /s /a AcroRd32.exe > " & @TempDir & "\_tmpFindAcroRd.txt", @ProgramFilesDir & "\Adobe", @SW_HIDE) If StringInStr(FileRead(@TempDir & "\_tmpFindAcroRd.txt"), "AcroRd32.exe") Then Return FileRead(@TempDir & "\_tmpFindAcroRd.txt") Else Return False EndIf FileDelete(@TempDir & "\_tmpFindAcroRd.txt") EndFunc So when I use the Run command to execute the program, nothing happens. Not even an error message!! I have no idea anymore... Maybe I am too blind to see the error. muttley I hope someone here can help me! Cheers TyJust for reference, with Adobe Reader 8.x, you can do a RegRead() for the default value of the key: HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\8.0\InstallPath That will give you the root directory for "AcroRd32.exe" Edited July 8, 2008 by Monamo - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup] Link to comment Share on other sites More sharing options...
weaponx Posted July 8, 2008 Share Posted July 8, 2008 Wouldn't this make more sense to get the path to the Reader EXE? $result = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe", "") MsgBox(0,"Adobe Reader Path", $result) Link to comment Share on other sites More sharing options...
Tyraenor Posted July 8, 2008 Author Share Posted July 8, 2008 Wouldn't this make more sense to get the path to the Reader EXE? $result = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe", "") MsgBox(0,"Adobe Reader Path", $result) Thanks!! That worked fine... Sometimes it is too bad... The easiest way and I tried it the difficult way... @Monamo: That would not work because of the version number... muttley Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now