How can I make a script executable in windows
Asked Answered
exe
R

3

20

How can I make a script executable in windows. just like what the chmod +x command does in linux. I have browsed but got no definite solution. Thanks for helping out.

Recipe answered 28/8, 2018 at 21:3 Comment(2)
What kind of script is it?Hon
I am not even the person that built the script. It is git-ftp client downloaded from github for uploading. In the installation guide a step is to chmod +x it ie making it executable but that is linux guide. am using windows so I need to make it executable as well on windows. It is a downloaded script to say, I dont know the type of script it is.Recipe
T
7

Run:

git add --chmod=+x filename

This git adds the file, and makes it executable before you then git commit to push.

Tatouay answered 17/1, 2023 at 23:39 Comment(0)
C
2

You need to give the file an executable extension. Windows executes .bat, .com and .exe files by default, but the PATHEXT environment variable determines which extensions can be executed without even writing out their extensions and in what order they will be tried.

What will be actually executed depends on the registry settings under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\, which are also edited by the "Open with..." graphical dialogs in the Explorer. For details about that, see the answer for a different question: https://mcmap.net/q/388808/-where-does-windows-store-its-quot-open-with-quot-settings

In your case the git-ftp script uses bash which is not pre-installed on most Windows machines. If your Windows edition supports the Windows Subsystem for Linux optional component, I suggest just installing that. But there are other options, like Cygwin, Wubi or a virtual machine.

As you wrote in your comment, Git for Windows includes an MSys2 bash shell, which is a successor of Cygwin in some sense.

Changteh answered 28/8, 2018 at 21:9 Comment(6)
I am not even the person that built the script. It is git-ftp client downloaded from github for uploading. In the installation guide a step is to chmod +x it ie making it executable but that is linux guide. am using windows so I need to make it executable as well on windows. It is a downloaded script to say, I dont know the type of script it isRecipe
On Linux the 1st line of file usually contains how that script should be run (opposed to Windows it is not the extension but the file content that determines how it should be run).Changteh
If you check this: github.com/git-ftp/git-ftp/blob/… it will be clear it is a bash script. Please update your question to point to this specific script, so the answer matches your question.Changteh
@Recipe Did it help you? Which way did you choose?Changteh
Thanks much @wigy. I used git bash directly to run the commands and it is working well like am running it on a linux os. Can't really explain why but that solved my problem. Thanks so much.Recipe
There must be a way to give a file +x, because when you execute ls -al you see: drwxr-xr-x. I see some python files have it, others don't, so don't tell me it is determined by the extension...Bullen
D
-1

"attrib +x filename" might work!

Diaeresis answered 11/4 at 10:39 Comment(2)
Welcome to Stack Overflow! Your answer could be improved with additional supporting information. If possible, please edit your post to add further details, such as explanations or documentation, so that others can confirm that your answer is correct. You can find more information in How do I write a good answer? - "Brevity is acceptable, but fuller explanations are better." It might be helpful to review some highly upvoted answers as examples to follow. Thanks!Morale
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Fortepiano

© 2022 - 2024 — McMap. All rights reserved.