How can I make a Windows shortcut that launches Bash and runs commands?Pass cmd.exe arguments via a shortcut?How to solve error: There is no script engine for file extension “.cmd”How to use /k to keep a command prompt shortcut from closing?How to find an 'orphaned' keyboard shortcut that can't be unbound?Make a shortcut to Ubuntu bash.exe on Windows 10 that doesn't auto-closeCreating a Script File to Call a Shortcut That Has a Complex Target and Closing the End Dialog WindowCMD Not Running 2nd Command ( & ) till first program is exitedHow to make a shortcut for VIRTUAL FOLDER from command line in windows 7?Windows File Type Association - Open bat in same powershell windowWindows shortcut, Command Line and Perl

Is a lawful good "antagonist" effective?

How does Dispel Magic work against Stoneskin?

Make a transparent 448*448 image

Should I tell my boss the work he did was worthless

Is it illegal in Germany to take sick leave if you caused your own illness with food?

Is all copper pipe pretty much the same?

Why would a jet engine that runs at temps excess of 2000°C burn when it crashes?

What exactly is the purpose of connection links straped between the rocket and the launch pad

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

Is King K. Rool's down throw to up-special a true combo?

Potentiometer like component

Do f-stop and exposure time perfectly cancel?

lmodern + tipa cause first instance of diacritic to break

How to deal with a cynical class?

What is the difference between "shut" and "close"?

Making a sword in the stone, in a medieval world without magic

How can I make a Windows shortcut that launches Bash and runs commands?

What Happens when Passenger Refuses to Fly Boeing 737 Max?

Do I really need to have a scientific explanation for my premise?

US to Europe trip with Canada layover- is 52 minutes enough?

Is going from continuous data to categorical always wrong?

Should QA ask requirements to developers?

BitNot does not flip bits in the way I expected

How do anti-virus programs start at Windows boot?



How can I make a Windows shortcut that launches Bash and runs commands?


Pass cmd.exe arguments via a shortcut?How to solve error: There is no script engine for file extension “.cmd”How to use /k to keep a command prompt shortcut from closing?How to find an 'orphaned' keyboard shortcut that can't be unbound?Make a shortcut to Ubuntu bash.exe on Windows 10 that doesn't auto-closeCreating a Script File to Call a Shortcut That Has a Complex Target and Closing the End Dialog WindowCMD Not Running 2nd Command ( & ) till first program is exitedHow to make a shortcut for VIRTUAL FOLDER from command line in windows 7?Windows File Type Association - Open bat in same powershell windowWindows shortcut, Command Line and Perl













2















I've created a windows shortcut with a target that looks like



"C:WindowsSystem32bash.exe" php /c/script.php



(I know I could just use my windows verison of php cli to run this, but out of curiosity)



When I click my shortcut it just pops open a cmd window and closes (where the script should take minutes to run.



Is there a way to pipe commands to bash.exe on windows?










share|improve this question







New contributor




Keith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • It's simple, just wait and hello world, so i should see something. But the cmd window pops open for a moment and closes.

    – Keith
    4 hours ago











  • Many things I see that are odd about this question. If it were WSL, then "/c/script.php" would be "/mnt/c/script.php".. it it were CYGWIN or MINGW, then bash.exe wouldn't be in Windows/System32. What 'Unix' are you using?

    – Señor CMasMas
    3 hours ago
















2















I've created a windows shortcut with a target that looks like



"C:WindowsSystem32bash.exe" php /c/script.php



(I know I could just use my windows verison of php cli to run this, but out of curiosity)



When I click my shortcut it just pops open a cmd window and closes (where the script should take minutes to run.



Is there a way to pipe commands to bash.exe on windows?










share|improve this question







New contributor




Keith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • It's simple, just wait and hello world, so i should see something. But the cmd window pops open for a moment and closes.

    – Keith
    4 hours ago











  • Many things I see that are odd about this question. If it were WSL, then "/c/script.php" would be "/mnt/c/script.php".. it it were CYGWIN or MINGW, then bash.exe wouldn't be in Windows/System32. What 'Unix' are you using?

    – Señor CMasMas
    3 hours ago














2












2








2








I've created a windows shortcut with a target that looks like



"C:WindowsSystem32bash.exe" php /c/script.php



(I know I could just use my windows verison of php cli to run this, but out of curiosity)



When I click my shortcut it just pops open a cmd window and closes (where the script should take minutes to run.



Is there a way to pipe commands to bash.exe on windows?










share|improve this question







New contributor




Keith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I've created a windows shortcut with a target that looks like



"C:WindowsSystem32bash.exe" php /c/script.php



(I know I could just use my windows verison of php cli to run this, but out of curiosity)



When I click my shortcut it just pops open a cmd window and closes (where the script should take minutes to run.



Is there a way to pipe commands to bash.exe on windows?







windows bash cmd.exe shortcuts windows-subsystem-for-linux






share|improve this question







New contributor




Keith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Keith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Keith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 4 hours ago









KeithKeith

1134




1134




New contributor




Keith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Keith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Keith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • It's simple, just wait and hello world, so i should see something. But the cmd window pops open for a moment and closes.

    – Keith
    4 hours ago











  • Many things I see that are odd about this question. If it were WSL, then "/c/script.php" would be "/mnt/c/script.php".. it it were CYGWIN or MINGW, then bash.exe wouldn't be in Windows/System32. What 'Unix' are you using?

    – Señor CMasMas
    3 hours ago


















  • It's simple, just wait and hello world, so i should see something. But the cmd window pops open for a moment and closes.

    – Keith
    4 hours ago











  • Many things I see that are odd about this question. If it were WSL, then "/c/script.php" would be "/mnt/c/script.php".. it it were CYGWIN or MINGW, then bash.exe wouldn't be in Windows/System32. What 'Unix' are you using?

    – Señor CMasMas
    3 hours ago

















It's simple, just wait and hello world, so i should see something. But the cmd window pops open for a moment and closes.

– Keith
4 hours ago





It's simple, just wait and hello world, so i should see something. But the cmd window pops open for a moment and closes.

– Keith
4 hours ago













Many things I see that are odd about this question. If it were WSL, then "/c/script.php" would be "/mnt/c/script.php".. it it were CYGWIN or MINGW, then bash.exe wouldn't be in Windows/System32. What 'Unix' are you using?

– Señor CMasMas
3 hours ago






Many things I see that are odd about this question. If it were WSL, then "/c/script.php" would be "/mnt/c/script.php".. it it were CYGWIN or MINGW, then bash.exe wouldn't be in Windows/System32. What 'Unix' are you using?

– Señor CMasMas
3 hours ago











2 Answers
2






active

oldest

votes


















1














First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:



wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php




Here is the wsl.exe usage information:




Usage: wsl.exe [Argument] [Options...] [CommandLine]



Arguments to run Linux binaries:



If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine>
Execute the specified command without using the default Linux shell.

--
Pass the remaining command line as is.



For further details, read WSL interoperabiltity with Windows.








share|improve this answer























  • Thank you for the heads up about bash.exe's deprecation. I'll use wsl from here on out. And your example worked perfectly, thank you!

    – Keith
    2 hours ago


















3














If this is WSL, use bash.exe -c "command to run" as in



C:WindowsSystem32bash.exe -c "vi ~/.bashrc"



or



C:WindowsSystem32bash.exe -c "php /mnt/c/script.php"






share|improve this answer























  • Thank you! The -c argument worked great. It was tough to choose which one to accept as answer as they're both great.

    – Keith
    2 hours ago











  • Yes I'm aware. afaik I can only accept one answer.

    – Keith
    1 hour ago










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "3"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Keith is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1413721%2fhow-can-i-make-a-windows-shortcut-that-launches-bash-and-runs-commands%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:



wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php




Here is the wsl.exe usage information:




Usage: wsl.exe [Argument] [Options...] [CommandLine]



Arguments to run Linux binaries:



If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine>
Execute the specified command without using the default Linux shell.

--
Pass the remaining command line as is.



For further details, read WSL interoperabiltity with Windows.








share|improve this answer























  • Thank you for the heads up about bash.exe's deprecation. I'll use wsl from here on out. And your example worked perfectly, thank you!

    – Keith
    2 hours ago















1














First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:



wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php




Here is the wsl.exe usage information:




Usage: wsl.exe [Argument] [Options...] [CommandLine]



Arguments to run Linux binaries:



If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine>
Execute the specified command without using the default Linux shell.

--
Pass the remaining command line as is.



For further details, read WSL interoperabiltity with Windows.








share|improve this answer























  • Thank you for the heads up about bash.exe's deprecation. I'll use wsl from here on out. And your example worked perfectly, thank you!

    – Keith
    2 hours ago













1












1








1







First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:



wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php




Here is the wsl.exe usage information:




Usage: wsl.exe [Argument] [Options...] [CommandLine]



Arguments to run Linux binaries:



If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine>
Execute the specified command without using the default Linux shell.

--
Pass the remaining command line as is.



For further details, read WSL interoperabiltity with Windows.








share|improve this answer













First of all, bash.exe has been deprecated. You should use wsl.exe in command lines. Use Windows Insiders Builds 17063 and above for the interoperability feature in WSL. For your case, both of this may work:



wsl.exe php /mnt/c/MyFiles/test.php
wsl.exe --exec php /mnt/c/MyFiles/test.php




Here is the wsl.exe usage information:




Usage: wsl.exe [Argument] [Options...] [CommandLine]



Arguments to run Linux binaries:



If no command line is provided, wsl.exe launches the default shell.

--exec, -e <CommandLine>
Execute the specified command without using the default Linux shell.

--
Pass the remaining command line as is.



For further details, read WSL interoperabiltity with Windows.









share|improve this answer












share|improve this answer



share|improve this answer










answered 3 hours ago









BiswapriyoBiswapriyo

3,24141344




3,24141344












  • Thank you for the heads up about bash.exe's deprecation. I'll use wsl from here on out. And your example worked perfectly, thank you!

    – Keith
    2 hours ago

















  • Thank you for the heads up about bash.exe's deprecation. I'll use wsl from here on out. And your example worked perfectly, thank you!

    – Keith
    2 hours ago
















Thank you for the heads up about bash.exe's deprecation. I'll use wsl from here on out. And your example worked perfectly, thank you!

– Keith
2 hours ago





Thank you for the heads up about bash.exe's deprecation. I'll use wsl from here on out. And your example worked perfectly, thank you!

– Keith
2 hours ago













3














If this is WSL, use bash.exe -c "command to run" as in



C:WindowsSystem32bash.exe -c "vi ~/.bashrc"



or



C:WindowsSystem32bash.exe -c "php /mnt/c/script.php"






share|improve this answer























  • Thank you! The -c argument worked great. It was tough to choose which one to accept as answer as they're both great.

    – Keith
    2 hours ago











  • Yes I'm aware. afaik I can only accept one answer.

    – Keith
    1 hour ago















3














If this is WSL, use bash.exe -c "command to run" as in



C:WindowsSystem32bash.exe -c "vi ~/.bashrc"



or



C:WindowsSystem32bash.exe -c "php /mnt/c/script.php"






share|improve this answer























  • Thank you! The -c argument worked great. It was tough to choose which one to accept as answer as they're both great.

    – Keith
    2 hours ago











  • Yes I'm aware. afaik I can only accept one answer.

    – Keith
    1 hour ago













3












3








3







If this is WSL, use bash.exe -c "command to run" as in



C:WindowsSystem32bash.exe -c "vi ~/.bashrc"



or



C:WindowsSystem32bash.exe -c "php /mnt/c/script.php"






share|improve this answer













If this is WSL, use bash.exe -c "command to run" as in



C:WindowsSystem32bash.exe -c "vi ~/.bashrc"



or



C:WindowsSystem32bash.exe -c "php /mnt/c/script.php"







share|improve this answer












share|improve this answer



share|improve this answer










answered 3 hours ago









Señor CMasMasSeñor CMasMas

1715




1715












  • Thank you! The -c argument worked great. It was tough to choose which one to accept as answer as they're both great.

    – Keith
    2 hours ago











  • Yes I'm aware. afaik I can only accept one answer.

    – Keith
    1 hour ago

















  • Thank you! The -c argument worked great. It was tough to choose which one to accept as answer as they're both great.

    – Keith
    2 hours ago











  • Yes I'm aware. afaik I can only accept one answer.

    – Keith
    1 hour ago
















Thank you! The -c argument worked great. It was tough to choose which one to accept as answer as they're both great.

– Keith
2 hours ago





Thank you! The -c argument worked great. It was tough to choose which one to accept as answer as they're both great.

– Keith
2 hours ago













Yes I'm aware. afaik I can only accept one answer.

– Keith
1 hour ago





Yes I'm aware. afaik I can only accept one answer.

– Keith
1 hour ago










Keith is a new contributor. Be nice, and check out our Code of Conduct.









draft saved

draft discarded


















Keith is a new contributor. Be nice, and check out our Code of Conduct.












Keith is a new contributor. Be nice, and check out our Code of Conduct.











Keith is a new contributor. Be nice, and check out our Code of Conduct.














Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1413721%2fhow-can-i-make-a-windows-shortcut-that-launches-bash-and-runs-commands%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Era Viking Índice Início da Era Viquingue | Cotidiano | Sociedade | Língua | Religião | A arte | As primeiras cidades | As viagens dos viquingues | Viquingues do Oeste e Leste | Fim da Era Viquingue | Fontes históricas | Referências Bibliografia | Ligações externas | Menu de navegação«Sverige då!»«Handel I vikingetid»«O que é Nórdico Antigo»Mito, magia e religião na volsunga saga Um olhar sobre a trajetória mítica do herói sigurd«Bonden var den verklige vikingen»«Vikingatiden»«Vikingatiden»«Vinland»«Guerreiras de Óðinn: As Valkyrjor na Mitologia Viking»1519-9053«Esculpindo símbolos e seres: A arte viking em pedras rúnicas»1679-9313Historia - Tema: VikingarnaAventura e Magia no Mundo das Sagas IslandesasEra Vikinge

What's the metal clinking sound at the end of credits in Avengers: Endgame?What makes Thanos so strong in Avengers: Endgame?Who is the character that appears at the end of Endgame?What happens to Mjolnir (Thor's hammer) at the end of Endgame?The People's Ages in Avengers: EndgameWhat did Nebula do in Avengers: Endgame?Messing with time in the Avengers: Endgame climaxAvengers: Endgame timelineWhat are the time-travel rules in Avengers Endgame?Why use this song in Avengers: Endgame Opening Logo Sequence?Peggy's age in Avengers Endgame

Are there legal definitions of ethnicities/races? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Legal definitions in the United StatesAre there truly legal limits on US interest rates?Are gender identity and sexual orientation federally protected?Why is there an apparent legal bias against digital services?What limits are there to the powers of individual judges in the United States legal system?Are women only scholarships legal under Irish / EU law?Is the term “race” defined by Public Law enacted by Congress of the United StatesIs there a legal definition of race in the US?Neighbors are spying for landlord on Renters is it legal?Are Protected Classes Bi-directional?