I have some bash scripts that I wanted to use like batch files in windows 10 by double clicking and let it to finish the job. Problem is it starts the script from windows system (C:\Windows\System32
) directory (I chose bash C:\cygwin\bin\bash.exe
to run .sh
scripts but they didn't work. After a while I have added read xyz
at the end to keep the script alive and checked in process explorer that it starts from windows system directory. This way script trying to create archive in there gets denied access).
Neither bash nor script is in that directory. In XP it used to work fine. In supposedly "modern" 10 it does not. How to change that so it starts in current/script directory?
[ed]
The script can be as simple as and is located in c:\tmp
:
#!/bin/sh
rar a bak.rar *.txt
After adding some debugging code:
#!/bin/sh
pwd
rar4 a bak.rar *.txt
read xyz
/cygdrive/c/WINDOWS/system32
(...)
Cannot create bak.rar
Access is denied.
pwd
evidently shows it's run from windows\system32 directory, which is the whole mystery.
C:\cygwin\bin\bash.exe
. An yes, There is a PATH toC:\cygwin\bin
.