 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
HotKeyIt
Joined: 18 Jun 2008 Posts: 2196 Location: GERMANY
|
Posted: Fri Mar 13, 2009 2:16 pm Post subject: |
|
|
| Sean wrote: | | Quote: | StdoutToVar_CreateProcess("dir") doesn't work, you have to write
StdoutToVar_CreateProcess("cmd /K dir") | Yes, it's a normal behavior. dir is not a stand-alone application, it's an internal command of the command prompt, cmd.exe. |
Thanks Sean, I thought it just does not work.
Are there any other commands that need cmd /K prefix?
Can you automate it in your function? So if a command fails cmd /k is added automatically, so it works same as in cmd?
Does it make sense? _________________ AutoHotFile - ToolTip(n,text,title,options) |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2219
|
Posted: Fri Mar 13, 2009 3:24 pm Post subject: |
|
|
| HotKeyIt wrote: | | Are there any other commands that need cmd /K prefix? | Just type Help in the command prompt, then you'll get a list of commands.
| Quote: | Can you automate it in your function? So if a command fails cmd /k is added automatically, so it works same as in cmd?
Does it make sense? | Although it seems to make sense, I'm not sure if it'll not have any side effect. |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 2196 Location: GERMANY
|
Posted: Fri Mar 13, 2009 5:26 pm Post subject: |
|
|
| Sean wrote: | | HotKeyIt wrote: | | Are there any other commands that need cmd /K prefix? | Just type Help in the command prompt, then you'll get a list of commands.
| Quote: | Can you automate it in your function? So if a command fails cmd /k is added automatically, so it works same as in cmd?
Does it make sense? | Although it seems to make sense, I'm not sure if it'll not have any side effect. |
So as far as I understand I can try to add "cmd /K " to any command to make sure it'll always work, right? _________________ AutoHotFile - ToolTip(n,text,title,options) |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2219
|
Posted: Sat Mar 14, 2009 3:46 am Post subject: |
|
|
| HotKeyIt wrote: | | So as far as I understand I can try to add "cmd /K " to any command to make sure it'll always work, right? | You're right, although I don't recommend it. If you insist to use it, however, you may perfer /c to /k. |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 2196 Location: GERMANY
|
|
| Back to top |
|
 |
Smurth
Joined: 13 Dec 2006 Posts: 104
|
Posted: Sat Apr 25, 2009 3:39 am Post subject: |
|
|
Very nice and usefull script Sean; thank you for posting.
| Metaxal wrote: | | Sean wrote: | | Metaxal wrote: | | However it seems to crash without notice when the command is not correct, like: | It's not a crash, it'll just execute ExitApp if failed to create a process as it's pointless to keep running then. |
Ah ok I see. Well, I d'ont like my app to exit when one function call fails
Fortunatly, this can easily be changed
|
So, could we say that it is safe to simply replace that "ExitApp" with "Return" ?
Does this have side effects ? |
|
| Back to top |
|
 |
Smurth
Joined: 13 Dec 2006 Posts: 104
|
Posted: Sat Apr 25, 2009 3:47 am Post subject: |
|
|
| Rizzo wrote: | | Are there any advantages with using the COM or not using the COM? |
I'm asking to myself the same question...  |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2219
|
Posted: Sat Apr 25, 2009 5:31 am Post subject: |
|
|
| Smurth wrote: | | So, could we say that it is safe to simply replace that "ExitApp" with "Return" ? | No problem if you do clean-up yourself: CloseHandle all the created anonymous pipe handles. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2219
|
Posted: Sat Apr 25, 2009 5:32 am Post subject: |
|
|
| Quote: | | Are there any advantages with using the COM or not using the COM? | They are now simply alternatives. You can use whatever you prefer. |
|
| Back to top |
|
 |
wakewatcher
Joined: 15 Jul 2006 Posts: 200
|
Posted: Sun May 10, 2009 9:41 pm Post subject: |
|
|
| Didn't want to hijack this thread with a self inflicted wound but I am struggling with parameters so asked about it over on the help board HERE. Thx. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2219
|
Posted: Mon May 11, 2009 6:07 am Post subject: |
|
|
| wakewatcher wrote: | | Didn't want to hijack this thread with a self inflicted wound but I am struggling with parameters so asked about it over on the help board HERE. Thx. | This has nothing to do with the script. You just have to properly enclose the parameters containing spaces in quotes. |
|
| Back to top |
|
 |
wakewatcher
Joined: 15 Jul 2006 Posts: 200
|
Posted: Mon May 11, 2009 9:49 am Post subject: |
|
|
| yep that's why I didn't want to de-rail this thread. But I'm glad you took a look as you found the misplaced " for me! Thanks. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4116 Location: Belgrade
|
Posted: Mon Jul 06, 2009 11:02 am Post subject: |
|
|
Hej Sean if you are still watching.
I modified function to support ExitCode (via ErrorLevel as usual) and made some trivial changes (changed func name and slightly param names and order so its more similar to Run command)
I also made formal documentation.
I will prolly add some more features when time comes to it, like injection of environment variables, and option not to block script (like Run command does).
Cheers and thx again for this awesomeness.
Function
Documentation _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2219
|
Posted: Tue Jul 07, 2009 1:49 am Post subject: |
|
|
| majkinetor wrote: | | Cheers and thx again for this awesomeness. | Thanks. Regarding ExitCode, I had prepared the following code, however, never needed to add it.
| Code: | While DllCall("GetExitCodeProcess", "Uint", hProcess, "UintP", nExitCode) && nExitCode=259
{
Sleep, 300
If A_Index = 10
{
DllCall("TerminateProcess", "Uint", hProcess, "Uint", 0)
Break
}
}
|
|
|
| Back to top |
|
 |
shajul_offline Guest
|
Posted: Tue Jul 07, 2009 7:02 am Post subject: Noob questions.. |
|
|
Two noob questions..
1. The ExitApp problem, i dont want my app to exit.. any help
| Code: | If Not DllCall("CreateProcess", "Uint", 0, "Uint", &sCmd, "Uint", 0, "Uint", 0, "int", True, "Uint", 0x08000000, "Uint", 0, "Uint", sDir ? &sDir : 0, "Uint", &si, "Uint", &pi) ; bInheritHandles and CREATE_NO_WINDOW
ExitApp |
2. What is best, as i am going to distribute the script that calls Rasdial.exe
- RASDIAL "%connection%" /disconnect
OR
- %comspec% /c RASDIAL "%connection%" /disconnect
Thanks.. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|