Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2005
    Posts
    7

    Running an exe in the same directory

    I'm building my project as a web/email executable and I want to run an application in the same directory as that executable (whereever it is run from) when a user clicks a button.

    I'm using this code but it doesnt seem to work.

    File.Open("myapp.exe", "", SW_SHOWNORMAL);

    Any help would be greatly appreciated.
    Jason

  2. #2
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843
    File.Open is to open a file. In order to run an exe, you need to use the File.Run action.

    Good luck
    Yossi

  3. #3
    Join Date
    Oct 2005
    Location
    Brazil - Belo Horizonte
    Posts
    118
    Quote Originally Posted by jason8
    I'm building my project as a web/email executable and I want to run an application in the same directory as that executable (whereever it is run from) when a user clicks a button.

    I'm using this code but it doesnt seem to work.

    File.Open("myapp.exe", "", SW_SHOWNORMAL);

    Any help would be greatly appreciated.
    Jason
    try this:

    get_current_folder = Folder.GetCurrent();
    run_myapp = File.Run("AutoPlay\\Docs\\myapp.exe", "", ""..get_current_folder.."", SW_SHOWNORMAL, false);

    If you copy the script above and paste it into a button, once you click on that button your AutoPlay Application will run myapp.exe from the same folder your executable is.

  4. #4
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    Take a look at my example I worked out for AMS 6 (works in AMS 6). It was even added to the Examples section for AMS 5:

    http://www.indigorose.com/forums/showthread.php?t=11327

    Or, here is the code:

    Code:
    --[[ NOTE:  This function only works AFTER you Build (F7) the project!
    
         The following function takes one argument (runexe = path and name of .exe)...
         and returns one string (strPath = the path of...
         the location of the .exe), NOT the temp ran-from location!
    ]]
    
    function fnEXEOrigLoca(runexe)
    	resFile = File.Run(runexe, "", "", SW_SHOWNORMAL, false)
    	
    	strCWF = Folder.GetCurrent()
    		strPath = String.Replace(_CommandLineArgs[1], "SFXSOURCE:", "", true)
    			return strPath;
    end
    
    -- An example "function call" (to use the function)
    fnEXEOrigLoca(_DesktopFolder.."\\app_name.exe")
    
        -- This Message box can be removed (it's just for visual feedback)
    	Dialog.Message("", strPath)
    Intrigued

  5. #5
    Join Date
    Dec 2005
    Posts
    7
    get_current_folder = Folder.GetCurrent();
    run_myapp = File.Run("AutoPlay\\Docs\\myapp.exe", "", ""..get_current_folder.."", SW_SHOWNORMAL, false);

    Thanks for the help but trying to use that doesn't work either.

    I've built a file called slideshow.exe in autoplay, and another file called player.exe. I dont want to put myapp.exe into slideshow's autoplay files.
    I want slideshow.exe and myapp.exe to be in the same directory and a button in slideshow.exe to run myapp.exe.

    Any suggestions?

    Thanks again

  6. #6
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    Jason, his code does not work because the Docs folder of the AMS project is not the home of the .exe at run-time. Please note my post below his (and one above your last post here). It shows you how to access the folder of the AMS .exe, again, at run-time. It works after you have built the project to a .exe.

    Work with that code and you will find success, for sure.

    Intrigued

  7. #7
    Join Date
    Dec 2005
    Posts
    7
    When I run this code, it only wants to run something in the desktop folder, i've tried to work out how to run a file from the same directory, but it keeps failing and in the dialog box it shows just the name and path of the exe I am running and not the one I want to run.

    function fnEXEOrigLoca(runexe)
    resFile = File.Run(runexe, "", "", SW_SHOWNORMAL, false)

    strCWF = Folder.GetCurrent()
    strPath = String.Replace(_CommandLineArgs[1], "SFXSOURCE:", "", true)
    return strPath;
    end

    -- An example "function call" (to use the function)
    fnEXEOrigLoca(_DesktopFolder.."\\app_name.exe")

    -- This Message box can be removed (it's just for visual feedback)
    Dialog.Message("", strPath)
    Any ideas?

  8. #8
    Join Date
    Dec 2005
    Posts
    7
    Figured it out now. Thank you.

    Code:
    local ncnt = Table.Count(_CommandLineArgs);
    	for n, cmline in _CommandLineArgs do
    		if (n == ncnt) then
    		strSFXmid = String.Mid(_CommandLineArgs[n], 11, -1); -- return string to right of SFXSOURCE:
    		strSFXApPath = String.SplitPath(strSFXmid).Drive..String.SplitPath(strSFXmid).Folder;
    		
    		Dialog.Message("Debug Only Notice", strSFXApPath);
    		File.Run(strSFXApPath.."\\myapp.exe", "", "", SW_SHOWNORMAL, false)
    		end
    	end

  9. #9
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    Great Jason! I know that feeling of victory you have just felt, oh, it's addictive!

    Intrigued

Similar Threads

  1. Error running secondary exe
    By darren in forum Setup Factory 6.0
    Replies: 2
    Last Post: 06-08-2004, 01:27 PM
  2. Multiple directory structures within Autoplay exe
    By Phil Merry in forum AutoPlay Media Studio 5.0
    Replies: 11
    Last Post: 05-19-2004, 05:51 AM
  3. Why does the EXE end up in the DOC directory?
    By Krusty in forum AutoPlay Media Studio 5.0
    Replies: 4
    Last Post: 04-29-2004, 04:12 AM
  4. HOWTO: Install Files to the Windows Directory
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 09-18-2002, 02:33 PM
  5. Running EXE from an MSI file
    By Mark in forum Setup Factory 5.0
    Replies: 1
    Last Post: 03-13-2001, 11:45 PM

Posting Permissions

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