Getting ASP.NET to see changes in PATH
I've changed the environment PATH
variable on my server and need IIS / W3WP (i.e. my ASP.NET app) to see this change. I understand from this other question's answer that (emphasis mine):
You'll have to recycle the IIS process to get it to update
My question: how do I "recycle" the IIS process?
Here are the things I've tried to solve this issue:
Use
iisreset
I've tried a few things. First thing I tried wasiisreset
, but my asp.net app did not pick up the path changes. To make sure I wasn't crazy I tried rebooting the server, which did work: the app now picks up the newPATH
.I'd love to know if there's a way I can prevent needing to reboot the entire machine just because I want my
PATH
changed in my ASP.NET application...One other thing that may be the case is that I misunderstood the other question (that the answerer there did mean
iisreset
when saying "recycle iis")? That doesn't explain whyiisreset
did not work for my situation, and rebooting the server did. Are there options foriisreset
that I'm missing?Searching the interwebs
I've also tried searching for solutions. From my first searches about myPATH
issues led to no real info (except aforementioned question). My second set of searches about recycling the IIS process don't work to well: I get info aboutiisreset
and how it may recycle worker processes.Restarting W3SVC
An answerer suggested restarting W3SVC (the "World Wide Web Publishing Service"), which seemed promising, but it also didn't work for me (it might work for you though!). I tried that suggestion by changing the path, using a fresh command prompt to verify the change came through, and restarted W3SVC: no dice for my ASP.NET application. After a reboot a fresh command prompt will still show the changed path, and my application will also see the change (so the change itself was in fact what I wanted).Another answerer suggested something similar, with one important difference: let the service remain stopped for a little bit, confirm in between that the site is unavailable (to see it's actually IIS serving that site). This had the same result for me though.
Killing the correct IIS process On a foot note, one final alternative I've considered is killing the svchost process for iis, as that seems like a rather brute solution. I've tried this and killed "
svchost.exe -k iissvcs
", but this didn't work either. But perhaps I just killed the wrong process.Changing the AppPool settings
The application pool for my app had a non-default setting "Load User Profile = False
" running under the theNetworkService
identity. I'm unsure (even after reading the inline explanation) what the setting does, but I could imagine it had some effect on thePATH
variable as seen by my app. Alas, setting it toTrue
didn't solve anything.
To add some final details just in the off case that they're important. In my scenario I'm trying to start bcp.exe
with something along these lines:
using (var process = new Process())
{
process.StartInfo.FileName = "bcp.exe";
process.StartInfo.Arguments = myArguments;
process.StartInfo.UseShellExecute = false;
process.Start();
// Code to handle the process exiting and use the output.
}
We require BCP version 11 but had version 10 on the server box. The tool has a standalone installer, which adds the following crucial bits to the PATH
:
C:\Program Files\Microsoft SQL Server\110\Tools\Binn
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\