Is there a replacement of linux's "command &" in windows? | Newbie | | Join Date: Oct 2008
Posts: 13
| | |
hello,
I know in linux the "&" right after a command line is used to put the execution of this command into the background.
The question is :Is there a substitution for this under the windows os?
thx~
-yogo
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | re: Is there a replacement of linux's "command &" in windows?
Maybe the "start <command>" command can be of any use.
kind regards,
Jos
|  | AdministratorVoR | | Join Date: Feb 2006 Location: South West UK
Posts: 6,171
| | | re: Is there a replacement of linux's "command &" in windows?
Moved to the Windows forum
|  | Expert | | Join Date: Jan 2008 Location: A city in my country ;)
Posts: 855
| | | re: Is there a replacement of linux's "command &" in windows?
Hello,
As Sir JosAh said, "start" command will help you out. Although if you want to run execution of command in background, then the exact syntax would be:
This will open a separate MS DOS editor window in background. (more information here).
NOTE- Thanks sir JosAH, I never knew that 'start' command exists inside Windows OSes. I just googled and found more about it. And so I would like to Thank you.
Thanks......
AmbrNewlearner
| | Newbie | | Join Date: Oct 2008
Posts: 13
| | | re: Is there a replacement of linux's "command &" in windows? Quote:
Originally Posted by ambrnewlearner Hello,
As Sir JosAh said, "start" command will help you out. Although if you want to run execution of command in background, then the exact syntax would be:
This will open a separate MS DOS editor window in background. (more information here).
NOTE- Thanks sir JosAH, I never knew that 'start' command exists inside Windows OSes. I just googled and found more about it. And so I would like to Thank you.
Thanks......
AmbrNewlearner hello,
I 've tried start command and yes it works! thank you!
but a little bit different form the code you posted:
/B create no windows but /MIN minimized the new window,the former is what I want :),thank sir JosAH offer such a good hint~
but here comes about another problem,I'm gonna to use "start" like this:
but my command would probably output to the stdout or stderr,I want to restrict this output,just like the linux's ">/dev/null 2>&1",the "echo off" doesn't work,then what could I do?
| | Newbie | | Join Date: Oct 2008
Posts: 13
| | | re: Is there a replacement of linux's "command &" in windows? Quote:
Originally Posted by Banfa Moved to the Windows forum sorry for the misposting
I'll be attentive next time
-yogo
|  | Expert | | Join Date: Jan 2008 Location: A city in my country ;)
Posts: 855
| | | re: Is there a replacement of linux's "command &" in windows? Quote:
Originally Posted by walsug /B create no windows but /MIN minimized the new window,the former is what I want :) Well, I thought that you said to run the command in background......
BTW, no problems.............. Quote:
Originally Posted by walsug but here comes about another problem,I'm gonna to use "start" like this:
but my command would probably output to the stdout or stderr,I want to restrict this output,just like the linux's ">/dev/null 2>&1",the "echo off" doesn't work,then what could I do? You can instead use redirection.
By using redirection (< or >) you can direct output/input from/to a program to a specific file or device. More information here. You can also search google for elaborated information about the same.
Hope this helps...........
AmbrNewlearner
| | Newbie | | Join Date: Oct 2008
Posts: 13
| | | re: Is there a replacement of linux's "command &" in windows? Quote:
Originally Posted by ambrnewlearner Well, I thought that you said to run the command in background......
BTW, no problems..............
You can instead use redirection.
By using redirection (< or >) you can direct output/input from/to a program to a specific file or device. More information here. You can also search google for elaborated information about the same.
Hope this helps...........
AmbrNewlearner hi,
I've hit this page and got some useful info,I knew the pipe "|" and redirection ">"or ">>",I don't want the application to generate extra file,so i do it as follows:
create a console application with an empty main(),which is named "null.exe" and placed in the same path as my application,then run my application like this: - start /B -myapp- 2>&1|null
to throw both stdout and stderr into a null operation.
To improve this,I have to replace the null.exe with an existing command that almost do nothing in this context.Then the booting command may be like this: - start /B -myapp- 2>&1 | cd .
which could also do the work above.
thanks for your hints
-yogo
|  | AdministratorVoR | | Join Date: Feb 2006 Location: South West UK
Posts: 6,171
| | | re: Is there a replacement of linux's "command &" in windows? Quote:
Originally Posted by walsug I don't want the application to generate extra file,so i do it as follows:
create a console application with an empty main(),which is named "null.exe" and placed in the same path as my application,then run my application like this: - start /B -myapp- 2>&1|null
to throw both stdout and stderr into a null operation. You don't need to create an application (null.exe), there is a null device (called nul) that you can pipe output to when you don't want it - start /B -myapp- 2>&1|nul
|  | Administrator | | Join Date: Oct 2006 Location: London - UK
Posts: 15,730
| | | re: Is there a replacement of linux's "command &" in windows?
@ECHO OFF
and
@ECHO ON
simply control whether or not the commands themselves are echoed to the screen. They have no bearing as to what is displayed from within the program itself.
As Banfa said, the Nul device is used to consign the general output (not errors) to the bit-bucket.
The absence of the /WAIT parameter to START is what allows it to run asynchronously. /B ensures it executes without creating a new window.
| | Newbie | | Join Date: Oct 2008
Posts: 13
| | | re: Is there a replacement of linux's "command &" in windows?
hi,
I tested the "|nul" that Sir.Banfa offered,but here popup a msgbox says:"指定されたデバイス、パス、またはファイルにアクセスできません。アクセス許可がない可能性が あります。"Then console says:"アクセスが拒否されました。"Both mean "access denied!Maybe you have no access right to this device",then what could I probably do?
-yogo
| | Newbie | | Join Date: Oct 2008
Posts: 13
| | | re: Is there a replacement of linux's "command &" in windows? Quote:
Originally Posted by NeoPa @ECHO OFF
and
@ECHO ON
simply control whether or not the commands themselves are echoed to the screen. They have no bearing as to what is displayed from within the program itself.
As Banfa said, the Nul device is used to consign the general output (not errors) to the bit-bucket.
The absence of the /WAIT parameter to START is what allows it to run asynchronously. /B ensures it executes without creating a new window. Now I've made it clear,it's not allowed to pipe("|") to NUL,insteat,you have to redirect to it(">"or">>"),the whole command line shall like this: - start /B -myapp- >nul 2>&1
Thanks to Banfa and Neopa,I've solved this problem,now I could perfectly replace the linux counterpart.
regards,
yogo.
|  | Administrator | | Join Date: Oct 2006 Location: London - UK
Posts: 15,730
| | | re: Is there a replacement of linux's "command &" in windows?
Indeed Yogo.
Redirecting and piping were added into DOS from Unix many years ago, even though it was already available in Unix well before DOS was even a twinkle in Microsoft's eye.
Essentially it was added to look like what was used in Unix, even though the implementation is fundamentally different (under the hood/bonnet). As some of the things that make it work the way it does are not available to DOS/Windows, I believe there are still some elements of it which are still not fully copied.
For most uses though, just copy Unix.
|  | Similar Microsoft Windows / Vista / XP / ME / 95 & 98 bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,449 network members.
|