Results 1 to 8 of 8

Thread: command to launch a .bat file?

  1. #1
    Join Date
    Sep 2015
    Posts
    32
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default command to launch a .bat file?

    Hi,

    My project is almost done.

    Is there any code/command/way to launch a .bat file ?

    Couldn't find any doc on that.

    Quick recap: I am very very very new to coding in general so if you actually write code to help me out, note that I probably won't be able to do anything beside copy/paste : P
    From the intel I gathered I *might* have to do it in c++ which is even trickier for me as the only experience I have is with qml (and is equal to something like 50hours : )

    Yours,
    --Jay

  2. #2
    Join Date
    Sep 2015
    Posts
    32
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: command to launch a .bat file?

    No one? : (

    Yours,
    --Jay

  3. #3
    Join Date
    May 2015
    Posts
    9
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: command to launch a .bat file?

    Hi:

    You can try code:
    Qt Code:
    1. ShellExecute(NULL,"open","filename.bat",NULL,NULL,0);
    To copy to clipboard, switch view to plain text mode 
    Hope this help.

  4. #4
    Join Date
    Sep 2015
    Posts
    32
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: command to launch a .bat file?

    I can see how it could work but I need friend to help me implement the code in my project.

    Will let you know.

    Cheers,
    --Jay

  5. #5
    Join Date
    May 2015
    Posts
    9
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: command to launch a .bat file?

    It depends of your application. You can execute it from a button or directly in your code how another instruction ...

  6. #6
    Join Date
    Sep 2015
    Posts
    32
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: command to launch a .bat file?

    I have almost all my code in qml, could you tell me what method/code I should use if I want to "activate" ShellExecute when pressing SPACE?

    I tried

    Qt Code:
    1. Keys.onSpacePressed: {
    2. ShellExecute(NULL,"open","filename.bat",NULL,NULL,0);
    3. }
    To copy to clipboard, switch view to plain text mode 

    But ShellExecute is not recognized.

    I tried to put this code in main.cpp and this time it seems to be recognized (i.e it is not underlined in red) but obviously something is missing : )

    Yours,
    --Jay
    Ps: I remind you guys that I started to code like a month ago, so I usually need very specific stuff. My theory on algorithm and the like is good but I lack the practice. Most problems comes from syntax issues and not knowing how to translate that algorithm into actual code : )
    Last edited by JaySDC; 7th October 2015 at 10:11.

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: command to launch a .bat file?

    I have no idea where that ShellExecute comes from, I definitely have no heard about it.

    Let your friend have a look at QProcess.

    Cheers,
    _

  8. #8
    Join Date
    Sep 2015
    Posts
    32
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: command to launch a .bat file?

    Well I could not find much on ShellExecute.

    What is sure is that when I put this line into the main.cpp, it's not underlined in red probably meaning that it could be used. Don't know how though.

    Will do for QProcess.

    Cheers,
    --Jay

Similar Threads

  1. Replies: 1
    Last Post: 16th July 2014, 08:40
  2. Replies: 27
    Last Post: 6th September 2013, 22:23
  3. how to get input file name from the command line?
    By mentalmushroom in forum Qt Programming
    Replies: 14
    Last Post: 25th May 2011, 13:48
  4. Launch app by opening a file
    By Windsoarer in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2009, 06:22
  5. Replies: 1
    Last Post: 13th May 2009, 03:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.