I'm attempting to configure a site in IIS on Windows 2016 using appcmd.exe. Specifically PHP and FastCGI. I'm running into an issue where specifying the arguments parameter with single quotes fails. I can't seem to figure out how to escape this or what incantation of quotes is required. Here's the command the does work:
%windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/fastCGI /+"[fullPath='c:\php\php-cgi.exe', arguments='-d open_basedir=E:\Web\www.example.com;E:\Sessions\www.example.com;E:\Logs\www.example.com;E:\Temp\www.example.com', maxInstances='0', instanceMaxRequests='10000']" /commit:apphost
With open_basedir on Windows I need
-d open_basedir=E:\Web\www.example.com;E:\Sessions\www.example.com;E:\Logs\www.example.com;E:\Temp\www.example.com
to be enclosed in single quotes. Like this:
-d open_basedir='E:\Web\www.example.com;E:\Sessions\www.example.com;E:\Logs\www.example.com;E:\Temp\www.example.com'
If I create the FastCGI application first without arguments, I can add them afterwards like this:
%windir%\system32\inetsrv\appcmd.exe set config /section:system.webServer/fastCGI /[fullPath='c:\php\php-cgi.exe'].arguments:"-d open_basedir='E:\Web\www.example.com;E:\Sessions\www.example.com;E:\Logs\www.example.com;E:\Temp\www.example.com'" /commit:apphost
This issue is that I can't change additional settings afterwards because I can't specify the single quoted path with appcmd.
I can accomplish this with the IIS Manager GUI and via C# code. So it's definitely possible to set it this way. I just can't seem to get the correct format for appcmd.
Configuration Editor
in the GUI to make your changes and then have a look at the generated AppCmd command using theGenerate Script
dialog.