Can't run drush from within website folder configured with IIS on Windows Server 2012 I am trying to setup Drupal 8 on Windows Server 2012 on IIS. I have installed PHP7.0 and Composer. Using Composer I then installed Drush globally using composer global require drush/drush:8.*. Drush was installed at C:\Users\Myusername\AppData\Roaming\Composer\vendor\drush\drush. I have set the Path variable for the user 'Myusername' to include C:\Users\Myusername\AppData\Roaming\Composer\vendor\bin.

The problem I have is that if I cd into the website folder as configured in IIS, and then run drush version, I receive the following error:

"C:\\inetpub\\wwwroot\\mysite\\vendor\\bin\\drush.php.bat" is not recognized as an internal or external command, operable program or batch file.


If I run the same command outside of the site folder as configured in IIS, then drush version executes successfully.

It seems that when run from within the web site folder it is trying to run drush from within the website project instead of using the globally installed drush. 

Any suggestions on how to get Drush running for the site?

Updated:

After some experimenting it seems that when I run Drush it looks for the closest vendor\bin directory. If it is not in the current directory, it works its way up the parent directories until it finds it. If it can’t find it, it uses the globally set one. For example, if I run drush from either C:\\inetpub, C:\\inetpub\\wwwroot then will get this error:

`"C:\inetpub\vendor\bin\drush.php.bat" is not recognized as an internal or external command, operable program or batch file.

If I run drush version from outsite of C:\\inetpub directory then it works correctly.
Drush Launcher solved the issue for me.

Step 1 Download drush.phar and put it in project root folder

Step 2 Create drush.bat file in project root folder and put following content (it will run phar in window)

@echo off
php "%~dp0\drush.phar" %*


Now it will use local drush.