Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Batch run app and close

  • 05-05-2009 1:28pm
    #1
    Registered Users, Registered Users 2 Posts: 1,190 ✭✭✭


    Is there anyway of running a batch script that will close after running the program (while the program is still open)?.
    currently i have just have a single line as follows
    cmd /c "C:\program.exe" but the console window stays up and doesn't disappear( i can still x it but i want it to do that automatically)


Comments

  • Closed Accounts Posts: 1,710 ✭✭✭RoadKillTs


    What if you have this at the end?

    cls
    @exit

    Not 100% on that one. Give it a shot.


  • Registered Users, Registered Users 2 Posts: 1,190 ✭✭✭wolfric


    Thanks for the suggestion but the /c parameter takes care of closing it at the end. I want the window to close without waiting for the program to close


  • Registered Users, Registered Users 2 Posts: 1,181 ✭✭✭ronkmonster


    use start notepad.exe


  • Registered Users, Registered Users 2 Posts: 1,190 ✭✭✭wolfric


    for what? i'm not trying to run notepad and the batch script was written in notepad but i don't see how that makes a difference?


  • Registered Users, Registered Users 2 Posts: 1,181 ✭✭✭ronkmonster


    start followed by your program to run

    notepad was just an example


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,190 ✭✭✭wolfric


    Just flashes up a new console window and nothing else (and keeps it open), It works with something like notepad but not by specifying a program in another directory.


  • Registered Users, Registered Users 2 Posts: 7,516 ✭✭✭BrokenArrows


    start followed by your program to run

    notepad was just an example

    just going to clarify as you dont seem to be explaining yourself too well.
    #batch file 1
    start notepad.exe
    

    this batch file will run notepad and the command window will close.
    #batch file 2
    notepad.exe
    

    this will open notepad and leave the command window open.


  • Registered Users, Registered Users 2 Posts: 1,190 ✭✭✭wolfric


    Okay yes that will close the original window that did the start but it'll still leave another window open. You're just creating 2 windows and closing the first one. Try this out yourself:
    i have 2 batch files. 1 called prog.bat 1 called prog2.bat
    prog1:
    start prog2
    prog2:
    "C:\program.exe"
    and i type in prog1 and the first window opens calls the second and closes but the second remains.


  • Registered Users, Registered Users 2 Posts: 1,181 ✭✭✭ronkmonster


    instead of this

    prog2:
    "C:\program.exe"

    it should be

    prog2:
    start "C:\program.exe"


    you need to use start each time you want to execute a program and close the dos prompt straight away


  • Registered Users, Registered Users 2 Posts: 1,190 ✭✭✭wolfric


    ok that gives me 2 empty windows and no program. start "C:\program.exe" does not work at all. I've tried writing it into the console straight just to make sure.

    I figured out the problem with start. The title is supposed to be in "" so the program is just taken as the title and not actually run.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,181 ✭✭✭ronkmonster


    what does program.exe do

    is it console based?


    EDIT

    remove the start from the first batch file
    should only be in the second one that launches the program.exe


  • Registered Users, Registered Users 2 Posts: 1,181 ✭✭✭ronkmonster


    wolfric wrote: »
    I figured out the problem with start. The title is supposed to be in "" so the program is just taken as the title and not actually run.

    can you explain this, "" are normally only needed for paths with spaces

    yours should work without them

    try remove the start from the first batch


  • Registered Users, Registered Users 2 Posts: 1,190 ✭✭✭wolfric


    Its not actually "C:\program.exe" i just did it to simply the whole thing

    Did a cd to fix it. Don't see why 2 batch scripts were needed i just did
    cd "C:\program files\prog\"
    start prog.exe
    exit

    so problem solved thank you all


  • Registered Users, Registered Users 2 Posts: 1,181 ✭✭✭ronkmonster


    is it working with " and moving the start to second batch?


  • Registered Users, Registered Users 2 Posts: 1,190 ✭✭✭wolfric


    no and no check my script earlier. i used a cd to change to the right directory so i wouldn't have to use "" in the start command and the second script wasn't needed at all i'm not sure why it was advised


  • Registered Users, Registered Users 2 Posts: 1,181 ✭✭✭ronkmonster


    the exit isn't needed normally.


Advertisement