Question

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;
proc.Start();
proc.WaitForExit();
proc.Close();

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

Can't Collect Information   
[Hardware Resources]
[Conflicts/Sharing]
Can't Collect Information   
[DMA]

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.

Was it helpful?

Solution

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.

SPSecurity.RunWithElevatedPrivileges(delegate()
{
    //Your code goes here
});
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top