Cygwin - 从“运行命令”运行脚本 [英] Cygwin - run script silenty from "run command"
问题描述
我有脚本可以说:
C:\foo.bsh
我想能够通过windows运行命令运行此命令:
I want to be able to run this command via the windows run command:
Start -> Run
Windows Key + R
并输入类似foo
但是,我不想看到一个cmd提示。此脚本为IDE执行一些预处理。我不想在IDE进程的生命周期打开cmd提示。
However, I do not want a cmd prompt to be visible. This script does some preprocessing for an IDE. I do not want the cmd prompt to be open for the lifetime of the IDE process.
我试过:
1)创建具有以下内容的bat文件:
1) Creating a bat file with the following contents:
c:\cygwin\bin\bash --login "C:\foo.bsh" (this fails because it keeps a cmd open)
2 )使用bat_2_exe_converter将上述bat文件转换为exe(不会使cmd静音)
2) Converting the above bat file to an exe using bat_2_exe_converter (does not make the cmd silent)
想法?
EDIT:到目前为止,解决方案建议从实际的cygwin shell中输入内容。我试图得到一个更快的解决方案有一些短我可以在Windows运行命令中键入。此外, nohup命令; exit
不会自动杀掉框 - 但我可以手动杀死它,而不会杀死IDE进程。
The solution so far suggests something to type from an actual cygwin shell. I am trying to get a faster solution by having something short I can type in the Windows run command. Also, the nohup command; exit
doesn't automatically kill the box - however I can manually kill it without killing the IDE process. The run command accepts shortcuts (.lnk's), bat's, exe's.
推荐答案
尝试使用 cygwin 。它是一个大的安装,一个完整的unix环境为您的Windows机器。假设您安装在 c:\cygwin\
。
Try the run.exe command of cygwin. It is a big install, a complete unix environment for your Windows machine. Suppose you installed it at c:\cygwin\
.
打开shell(bash) code> man run 。
Open the shell (bash) and type man run
.
没有神秘感,只需运行 c:\cygwin\bin\\ \\ run.exe< your command here>
,您将执行您的无dos窗口。
No mystery, just run c:\cygwin\bin\run.exe <your command here>
and you will have your no dos window execution.
您可以从任何DOS窗口运行它(从开始菜单运行cmd.exe)。您不需要从cygwin运行它。
You can run it from any DOS window (run cmd.exe from the start menu). You don't need to run it from cygwin.
为了方便起见,请附加 C:\cygwin\bin
到您的%PATH%env var(我的电脑→属性→高级→环境变量)(Kudos to Felipe Alvarez注释)。
To make it easier, append C:\cygwin\bin
to your %PATH% env var (My Computer → Properties → Advanced → Environment Variables) (Kudos to Felipe Alvarez comment).
/ p>
Now you can just type
run "C:\foo.bsh"
这是runcommand的手册页:
Here is the man page of the runcommand:
$ man run
RUN(1) run 1.3.0 RUN(1)
NAME
run - start programs with hidden console window
SYNOPSIS
run [ -p path ] command [ -wait ] arguments
runcommand [ -p path ] [ -wait ] arguments
DESCRIPTION
Windows programs are either GUI programs or console programs. When
started console programs will either attach to an existing console
or create a new one. GUI programs can never attach to an exiting con‐
sole. There is no way to attach to an existing console but hide it if
started as GUI program.
run will do this for you. It works as intermediate and starts a pro‐
gram but makes the console window hidden.
With -p path you can add path to the PATH environment variable.
Issuing -wait as first program argument will make run wait for program
completition, otherwise it returns immediately.
The second variant is for creating wrappers. If the executable is
named runcommand (eg runemacs), run will try to start the program (eg
emacs).
EXAMPLES
run -p /usr/X11R6/bin xterm
run emacs -wait
runemacs -wait
run make -wait
AUTHORS
Charles S. Wilson
Harold L Hunt II
Jehan Bing
Alexander Gottwald
Version 1.3.0 November 2005 RUN(1)
这篇关于Cygwin - 从“运行命令”运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!