mentosan Posted June 19, 2018 Share Posted June 19, 2018 Hi there ! I have a script which at certain point will open a Windows cmd prompt terminal. How can I close the opened cmd window just using the Exit option from the tray? Selecting Exit from the tray will only stop the execution of the script but will not close the cmd window. Thx Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 19, 2018 Moderators Share Posted June 19, 2018 @mentosan since AutoIt can do anything the cmd prompt can do, why not just skip the window altogether? Then you can control the stop and start of that specific action in your script. It would also be easier to assist if you posted an example of what you're trying to accomplish. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
mentosan Posted June 19, 2018 Author Share Posted June 19, 2018 @JLogan3o13 Thank you for reply. I would prefer to stick with cmd because it will connect to a linux server and from there sending commands, using autocomplete and so on. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 19, 2018 Moderators Share Posted June 19, 2018 So it sounds like you're trying to manage an SSH connection, not a cmd prompt, correct? Again, the more information you provide about what you are trying to accomplish, the less teeth we have to pull to help "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
orbs Posted June 19, 2018 Share Posted June 19, 2018 @mentosan, accepting your will to work manually in the spawned process, your solutions would be: 1) to introduce your own custom "Exit" tray menu item to replace the default "Exit" with a function that will close the spawned process and then exit the script. see the help file for TrayCreateItem() function. 2) to register an "on exit" function in your script to do that. see the help file for OnAutoItExitRegister() function. that said, and as posted above, if your spawned process is doing repetitive and standard actions, you can consider automate it all together. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
mentosan Posted June 20, 2018 Author Share Posted June 20, 2018 This would achieve my goal, I think. @orbs Could you please post a short example on what you have suggested ? Basically, a part of the script is like this: If @error Then MsgBox( "Error: ".....) Else RunWait(cmd.... When I exit the script I want that cmd window will close too. Thank you Link to comment Share on other sites More sharing options...
orbs Posted June 20, 2018 Share Posted June 20, 2018 any particular reason for using RunWait() rather than Run()? Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
mentosan Posted June 21, 2018 Author Share Posted June 21, 2018 That's because the script must wait until return of the DOS commands or Linux commands. Link to comment Share on other sites More sharing options...
Developers Jos Posted June 21, 2018 Developers Share Posted June 21, 2018 On 6/19/2018 at 4:29 PM, JLogan3o13 said: So it sounds like you're trying to manage an SSH connection, not a cmd prompt, correct? Again, the more information you provide about what you are trying to accomplish, the less teeth we have to pull to help Guess this got lost for the OP as there still isn't much information to go on... Jos Somerset 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Somerset Posted June 21, 2018 Share Posted June 21, 2018 Okay, you earned that. Link to comment Share on other sites More sharing options...
orbs Posted June 21, 2018 Share Posted June 21, 2018 On 6/19/2018 at 6:12 PM, orbs said: register an "on exit" function in your script to do that. see the help file for OnAutoItExitRegister() function. @mentosan, i'd go explore the method stated above. i doubt any example i could give would serve your purpose better than you actually reading that help section and implementing it for your scenario. i would also advise, should you post again in this topic, post a working reproducer. your entire script is not required; a small independent script performing (or failing to perform) the task is expected, so anyone wishing to lend you a hand can easily run it on their own environment, test its functionality and suggest solutions or improvements. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
mentosan Posted June 26, 2018 Author Share Posted June 26, 2018 (edited) ok Edited July 6, 2018 by mentosan Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now