Cygwin - 从“运行命令"运行脚本静默 [英] Cygwin - run script silenty from "run command"

查看:29
本文介绍了Cygwin - 从“运行命令"运行脚本静默的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有脚本可以说:

C:foo.bsh

我希望能够通过 windows run 命令运行此命令:

开始 ->跑Windows 键 + R

然后输入一些像foo"这样的小东西然后按回车.

但是,我不希望 cmd 提示可见.此脚本为 IDE 执行一些预处理.我不希望 cmd 提示符在 IDE 进程的整个生命周期内都打开.

我试过了:

1) 创建一个 bat 文件,内容如下:

c:cygwininash --login "C:foo.bsh" (这失败,因为它保持 cmd 打开)

2) 使用bat_2_exe_converter将上述bat文件转换为exe文件(不让cmd静音)

想法?

目前的解决方案建议从实际的 cygwin shell 中输入一些内容.我试图通过在 Windows 运行命令中输入一些简短的内容来获得更快的解决方案.另外,nohup 命令;exit 不会自动杀死该框 - 但是我可以在不杀死 IDE 进程的情况下手动杀死它.运行命令接受快捷方式(.lnk 的)、bat 的、exe 的.

解决方案

试试cygwin.这是一个很大的安装,为您的 Windows 机器提供一个完整的 unix 环境.假设您将它安装在 c:cygwin.

没有什么神秘的,只要运行 c:cygwinin un.exe <你的命令在这里>,你就会有你的 no dos 窗口执行.

您可以从任何 DOS 窗口运行它(从开始菜单运行 cmd.exe).您不需要从 cygwin 运行它.

为了更简单,将 C:cygwinin 附加到您的 %PATH% 环境变量(我的电脑 → 属性 → 高级 → 环境变量)(感谢 Felipe Alvarez 的评论).

现在你可以直接输入

c:cygwinin
un.exe "C:foo.bsh";

您必须使用此命令在开始"菜单中创建一个链接,以便能够使用 Win-R 运行它.

这是运行命令的手册页:

$ man run运行(1) 运行 1.3.0 运行(1)名称运行 - 启动带有隐藏控制台窗口的程序概要运行 [ -p path ] 命令 [ -wait ] 参数运行命令 [ -p 路径 ] [ -wait ] 参数描述Windows 程序要么是 GUI 程序,要么是控制台程序.什么时候启动的控制台程序将附加到现有的控制台或创建一个新的.GUI 程序永远不能附加到现有的配置上唯一.没有办法附加到现有的控制台,但在以下情况下隐藏它作为 GUI 程序启动.run 会为你做这件事.它作为中间件工作并启动一个亲gram 但隐藏控制台窗口.使用 -p path 您可以将路径添加到 PATH 环境变量.发出 -wait 作为第一个程序参数将使运行等待程序完成,否则立即返回.第二个变体用于创建包装器.如果可执行文件是名为 runco​​mmand(例如 runemacs),run 将尝试启动程序(例如emacs).例子运行 -p/usr/X11R6/bin xterm运行 emacs -waitrunemacs -wait运行 make -wait作者查尔斯·S·威尔逊哈罗德·L·亨特二世杰汉兵亚历山大·戈特瓦尔德版本 1.3.0 2005 年 11 月 RUN(1)

I have script lets say:

C:foo.bsh

I want to be able to run this command via the windows run command:

Start -> Run
Windows Key + R

and type something small like 'foo' and hitting return.

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.

I have tried:

1) Creating a bat file with the following contents:

c:cygwininash --login "C:foo.bsh" (this fails because it keeps a cmd open)

2) Converting the above bat file to an exe using bat_2_exe_converter (does not make the cmd silent)

thoughts?

EDIT: 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.

解决方案

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.

No mystery, just run c:cygwinin un.exe <your command here> and you will have your no dos window execution.

You can run it from any DOS window (run cmd.exe from the start menu). You don't need to run it from cygwin.

To make it easier, append C:cygwinin to your %PATH% env var (My Computer → Properties → Advanced → Environment Variables) (Kudos to Felipe Alvarez comment).

Now you can just type

c:cygwinin
un.exe "C:foo.bsh"

You must create a link in your Start Menu with this command so will be able to run it with Win-R.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆