Help with closing cmd window after code has run

oobymach 0 Reputation points
2023-03-01T08:25:40.2966667+00:00

Here's my code

set x=createobject("wscript.shell")
x.run "%comspec% /k ""C:\Users\Go\Desktop\Debug\PBO2 tuner Shortcut.lnk"""

Which works to run the shortcut with arguments intact but it leaves an open cmd window afterwards, adding exit and quit at the end produced errors running the script, any help is appreciated.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,543 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Castorix31 81,361 Reputation points
    2023-03-01T09:01:15.9933333+00:00

    You don't need %comspec% /k to launch a link with parameters or not

    For example, this launches Notepad with a txt file :

    set x=createobject("wscript.shell")

    x.run "C:\Users\Christian\Desktop\TestNotepadLink.lnk ""e:\test.txt"""

    0 comments No comments

  2. Limitless Technology 43,916 Reputation points
    2023-03-01T16:44:22.1933333+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query

    You can try this command instead:

    start /wait cmd.exe /c "my_command.bat"

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments

  3. Limitless Technology 43,916 Reputation points
    2023-03-01T16:44:37.64+00:00

    Double post

    0 comments No comments