问题
So we have a service running on Server 2008 which kicks off a process (C# app) which does some rendering. The process is running successfully but it is using the system fonts (Arial I believe) instead of fonts which are supposed to be loaded. If I run this process manually by logging into the server, the fonts load successfully and the process renders correctly.
I have tried running this process by using CreateProcessWithLogonW but that still doesn't work. I am assuming this has to do with the non-interactive sessions in Server 2008 but I can't figure out how to solve it.
回答1:
I ended up solving this by using PSExec using the -i and -h options. From what I understand, it runs CreateProcessWithLogonW or something similar under the scenes. This correctly created a new session with a user account outside of session0. The only thing I had to do was make sure that the EULA for PSExec was accepted for the user I was attempting to run the process with. I also ran the "Interactive Services Detection" service just in case the EULA popped up in session0. After that I turned off "Interactive Services Detection" as I no longer needed it (not really sure that I needed to do this last step).
回答2:
I know you found a solution, but I had a very similar issue to yours (running an application through a scheduled task would use the default font but when running locally it would find the custom font I installed) and I found a different solution; On Server 2008, there is an issue where custom fonts are not registered immediately after installing for non-interactive users, whereas regular users (i.e. when running on a user actually logged in to the machine) do have the font registered immediately.
The solution that worked for me was to simply restart the machine the font was installed on and the font started working under the non-interactive accounts, as when the computer is turned on it registers correctly. It appears the font installation has a bug where it doesn't register the font correctly for non-interactive users until a reboot.
来源:https://stackoverflow.com/questions/5860939/windows-server-2008-special-fonts-during-rendering