I am trying to switch users in Cygwin using Cygwin's login
command. It throws an error saying:
/bin/bash: No such file or directory. Operation not permitted.
I am new to Cygwin. How I can switch between users?
I don't know why login doesn't work. But I have an easy workaround for this, running cygwin as the desired user, you can use RUNAS or automatize something using PSEXEC.
RUNAS:
runas /user:HOSTNAME\<user> D:\cygwin-64\Cygwin.bat
PSEXEC:
psexec \\HOSTNAME -u DOMAIN\<user> -p <password> D:\cygwin-64\Cygwin.bat
You even can pass commands/run scripts silently to Cygwin like this:
psexec -accepteula \\HOSTNAME -u DOMAIN\<user> -p <password> D:/cygwin-64/bin/run.exe /usr/bin/bash -lic \"/home/username/file.sh\"
Although the question is quite old maybe someone else is looking for this. I've documented this and other options here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With