I am creating a new process on my Sharepoint 07 web application. I've run the same command as below and works on my OS but not on my web app. I wanted to know why and if this is even possible. Here's code that creates the process.

string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"report.txt"); 
Process proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = "msinfo32.exe";
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.Arguments = "/report " + filePath;

It creates a file with every field as Can't collect information, example:

Can't Collect Information   
[Hardware Resources]
Can't Collect Information   

I am tempted to think Sharepoint doesnt allow any process to access the underlying hardware information. Is there a way to grant privilege to run this process?

Am I doing it wrong, are there settings to enable on sharepoint in order to run msinfo32?

WMI is enabled on my OS.


You can try running the code in elevated mode.

Also make sure the web application app pool account has Write Permission on the directory where the file is being created.

    //Your code goes here
|improve this answer|||||
  • Thanks Amal, that really did get the job done. I want to follow up on your solution though. So that's changes in the code to elevate privileges, is it possible to elevate privileges some how on the server (sharepoint/iis)? – lzc May 12 '15 at 19:26
  • When we elevate the code, the code gets executed in APP Pool Account context and no under current user context. We do this all the time when we want to execute similar tasks. You don't need to make any changes in IIS as such. – Amal Hashim May 12 '15 at 19:28
  • is it possible to force application code to run in the App Pool Account Context with making a change to a server setting? This may be dangerous but it can be used to help identify if the problem is actually priviledge. – lzc May 12 '15 at 19:31
  • Either you run the code in elevated mode, or use System Account to login and then run the code. I dont think its wise to make changes in the System. This is the very reason Microsoft has give the option to elevate code block. – Amal Hashim May 12 '15 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.