none
Can I tell a Program.run which folder to run in RRS feed

  • Question

  • HI can anyone tell me if I can tell the Program.Run where the .exe I am calling should run.

    I am using Dialogs.AskForFile() and when I call an .exe with the Program.Run it runs in the folder that the file selected from the Dialogs.AskForFile() was in and I need to to run in C:\example

    Can I either tell my program where i should be sitting eg. in C:\example or tell Program.Run to run in C:\example

    Thanks

    Chris


    Thursday, June 13, 2013 9:57 AM

Answers

  • Hmmm

    I can't give you a perfect answer, but I have an idea.

    Write a new program which only contains the CMD command.

    Save it at your main directory. Than call it with Program.Run and Dialog.AskForFile().

    This should not stop your main program but will start the needed .exe in myfolder.

    I hope this works.


    Mit freundlichen Grüßen Timo Greetings Timo

    • Marked as answer by Chris Swankie Thursday, June 13, 2013 1:45 PM
    Thursday, June 13, 2013 1:27 PM

All replies

  • There isn't a task called "Dialogs" in the original SmallBasic. Do you use an extension or another programming language? If the last is right, you should ask in the forum of this language.

    I only know one way. Copy the file to the right directory and run it there.

    It may look like this in C#:

    a = Dialogs.AskForFile() //Here you get your file. If you don't get the file path back, you need to get it and set it to "a"
    File.Copy(a, Program.Directory) //Here you copy your file to the program directory.
    Program.Run(Path.Combine(Program.Directory + "TheFileName.exe") //Here you run the .exe file.


    Mit freundlichen Grüßen Timo Greetings Timo

    Thursday, June 13, 2013 11:25 AM
  • Yes I am using an extension. I'm not having a problem copying a file.I don't have the Path.Combine is this an add in and am i correct in saying all this will do is the same as

    Program.Run(C:\myfolder\my.exe)

    What i need to do is run the my.exe in the C:\myfolder not from the C:\myfolder in C:\myprogramfolder

    Thursday, June 13, 2013 11:37 AM
  • Path.Combine is a command from another language. I mixed it a bit. Sorry for that. You can ignore it, because you use SmallBasic with an extension.

    What's the name of the extension?

    Now, I don't understand your question. You want to run your .exe file at C:\myfolder. But than you say, that you don't want to run it at the program directory. But C:\myfolder is the program directory or not?

    If you want to run a file in another directory, you must copy it to this directory. Than youse the new path to start it.


    Mit freundlichen Grüßen Timo Greetings Timo

    Thursday, June 13, 2013 12:02 PM
  • Sorry let me be clearer

    C:\myprogramfolder\MySBprogram.exe calls with the Program.run(C:\myfolder\called.exe)

    which needs to run in the C:\myfolder directory what happens is that the called.exe runs in the C:\myprogramfolder dir not the C:\myfolder dir or if i have uesd the Dialogs.AskForFile()

    as in a = Dialogs.AskForFile() which got the file name F:\a.file

    Then called.exe runs in F:\ not C:\myfolder

    If I use CMD.RunCMDcommand("c: & cd \ & cd myfolder & called /batch") it works fine but will wait for called.exe to finish before moving on in my code

    Thursday, June 13, 2013 12:23 PM
  • Hmmm

    I can't give you a perfect answer, but I have an idea.

    Write a new program which only contains the CMD command.

    Save it at your main directory. Than call it with Program.Run and Dialog.AskForFile().

    This should not stop your main program but will start the needed .exe in myfolder.

    I hope this works.


    Mit freundlichen Grüßen Timo Greetings Timo

    • Marked as answer by Chris Swankie Thursday, June 13, 2013 1:45 PM
    Thursday, June 13, 2013 1:27 PM
  • Thanks that is a great idea and will work fine.

    Chris

    Thursday, June 13, 2013 1:45 PM
  • Thanks. :)

    Mit freundlichen Grüßen Timo Greetings Timo

    Thursday, June 13, 2013 2:59 PM