Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
237 views
in Technique[技术] by (71.8m points)

Cygwin - run script silenty from "run command"

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.

question from:https://stackoverflow.com/questions/673278/cygwin-run-script-silenty-from-run-command

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...