Cygwin - run script silenty from “run command”

2019-01-13 08:16发布

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:\cygwin\bin\bash --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.

7条回答
祖国的老花朵
2楼-- · 2019-01-13 08:34

It has been bugging me for a while I couldn't find the solution for this, but I finally got the right mix together.

You can simply do the following if you have cygwin on your PATH:
run bash test.js

If cygwin is not on your path, you can do this:
c:\cygwin\bin\run.exe -p /bin bash test.js

If you are looking for more control over the created window (maximize, etc) it looks like you can use cygstart also.

Sources:
- neves answer above (though that wasn't enough by itself for me personally to figure it out)
- http://cygwin.com/ml/cygwin/2008-09/msg00156.html

查看更多
登录 后发表回答