I was using visual studio 2008 with parallel studio xe2011 to do fortran code, sometimes I also use visual studio 2022 community version. I set the cmd prompt for ifort compiler in External Tools and put the directory of ifortvars.bat in arguments. They work well all the time.
I encountered the problem yesterday. When I opened the cmd prompt, it showed "WindowsSdkDir not found" and could not generate a .exe file. it happens for both my vs2008 and vs2022.
I tried several methods according to some essays online, but always no luck.
After all the trials, I found that: if I open the cmd prompt in vs2008 or vs2022 without opening a file (in a target directory), and then I redirect it to my target directory by command cd, it works as before without a "WindowsSdkDir not found" warning. If I open the file in my target directory and then open the cmd prompt, the warning shows and it fails to compile. It seems my visual studio can only find a "WindowsSdkDir" in its initial directory?
I already defined the environment variable "WindowsSdkDir" in my system. But when I tried to show all my environment variables by running "set" in the cmd prompt from my visual studio, I couldn't find it in the list even though I ran it as admin.
It seems I should find a way to help my visual studio find somewhat named "WindowsSdkDir". would you please give me any suggestions regarding this problem?
