"Permission Denied" using cygwin in Windows

Mike picture Mike · Dec 18, 2010 · Viewed 81.7k times · Source

Background: I am trying to write a [.bat] file so I can double click it and a bash script will get invoked. The bash script will start up a few windows GUI apps to monitor GPU/CPU temperatures. I just did a fresh install of cygwin v1.7.7-1 (downloaded today) and windows 7.

Code: monitor-temps.bat:

C:\cygwin\bin\bash.exe ~/bin/monitor-temps.bash
pause

Code: monitor-temps.bash:

#!/usr/bin/bash
"/cygdrive/c/Users/michael/Desktop/apps_and_drivers/GPU-Z.0.4.8.exe" &

Output: After I double click the [.bat] file, I get a:

C:\Users\michael\Desktop>C:\cygwin\bin\bash.exe ~/bin/monitor-temps.bash

C:\Users\michael\Desktop>pause
Press any key to continue . . . /home/michael/bin/monitor-temps.bash: line 2: /cygdrive/c/Users/michael/Desktop/apps_and_drivers/GPU-Z.0.4.8.exe: Permission denied

I still get the same permissions error when I cd to the directory and manually execute the application.

Permissions: From my experience with permission problems in Linux, everything looks good because I am the user I think I am, and the file has the expected permissions:

$ whoami
michael

$ ls -l GPU*
-rwx------+ 1 michael        None 890720 2010-12-01 19:23 GPU-Z.0.4.8.exe

Question: Does anyone know how to fix this? Am I missing something?

Answer

Darkstrumn picture Darkstrumn · Jan 23, 2015

As a Developer, I use a shortcut to provide a command-line interface (CLI) that behaves similar to Linux, in my Windows environment, and ran into the same issue trying to untar a file.

The fix was to set the shortcut to "Run as Administrator".

If you are using this method to access your Cygwin environment, go to the properties of the shortcut, select the Advanced button to get the options to "Run as Administrator", check the box, click Ok. And off you go!! You can also set your batch file to do this, by making a shortcut to it and doing the above.

Hope that helps!