Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Command line batch file question

  • 13-03-2017 01:25PM
    #1
    Registered Users, Registered Users 2 Posts: 689 ✭✭✭


    Wondering if anyone can help with this...

    I have a batch file I've written to act as an intermediary step for users. It's intended to check for updates to config files from the server, copy them to the local machine and then launch our application. It's performing the first two steps without an issue, how ever when it launches the application, using a preconfigured shortcut, it hangs without ever getting to the final line of the batch, exit. It does launch the application successfully, however it doesn't seem to register this and move to the next line:



    set servershare=\\server\share\config files
    set localfolder=c:\config files

    If exist "%localfolder%\created.txt" (goto :begininicopy) else (goto :beginconfigfilescopy)

    :begininicopy

    xcopy "%servershare%\config.ini" "%localfolder%" /Y

    goto :progstart

    :beginconfigfilescopy

    md "%localfolder%"
    xcopy "%servershare%" /s "%localfolder%"
    copy NUL "%localfolder%\created.txt"

    goto :progstart

    :progstart

    "%localfolder%\Program.lnk"

    exit

    So it runs all the condition checks correctly, creating the local folder if it doesn't exist, etc, but after running the shortcut ("%localfolder%\Program.lnk") it just sits there in an open command window, without ever running the exit command. Any suggestions on a method of forcing the exit command to be run post the program launch or a method for 'timing out' the program run command as we know it is working?


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 2,300 ✭✭✭ItHurtsWhenIP


    Try calling the shortcut:
    call "%localfolder%\Program.lnk"
    


  • Registered Users, Registered Users 2 Posts: 689 ✭✭✭Evac101


    Try calling the shortcut:
    call "%localfolder%\Program.lnk"
    

    Cool - also was about to update that I had a colleague suggest using:
    Start "" "%Localfolder%\Program.lnk" /Y
    

    which worked. Essentially the issue seems to be that without some intermediary step (such as Start or Call) the cmd window remains open until the program which was launched, is closed, effectively pausing.

    Thanks for the assistance in any case - appreciated :)


Advertisement