Application not running from production web server
I have to run a tool from our internal website. There are few inputs that user will provide from UI and then I want to run the tool with user credential. My code works fine when I run it from my local machine, but when I deploy it to production server and try to execute it from there it does not start anything.
Here is my code, any advice will be greatly appreciated.
System.Diagnostics.ProcessStartInfo PSI = new Syste开发者_运维知识库m.Diagnostics.ProcessStartInfo(@"D:\run.bat");
PSI.UserName = "username";
PSI.Domain = "domain";
System.Security.SecureString securePwd = new System.Security.SecureString();
string password = "password";
foreach (char c in password)
{
// Append the character to the password.
securePwd.AppendChar(c);
}
PSI.Password = securePwd;
PSI.UseShellExecute = false;
process.StartInfo = PSI;
PSI.Arguments = SiteId.Text + " " + WebServiceUrl.Text + " " +LogFile.Text;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
First:
- Check the identity of your application pool (advanced settings).
- Switch the identity to "system" and see if the batch file runs from the web app.
If it does:
- Change the identity back to network service,
- Make sure your batch file has execute permissions applied for user Network Service (or whichever identity you chose)
If it doesn't:
- Try opening the file with your code and appending some harmless text to the end.
- If that works, you can at least rule out permissions and web-app view-ability concerns.
I want to close this thread as my problem of running an application from production server solved. But I'm facing issue to run that application using specific user name & password. It always run with whatever identity is set in apppool. So for now if I only use this line it works on app pool default identity
Process.Start("notepad");
But if I use this line of code it don't even start a notepad in that server
string password = "XXXXX";
System.Security.SecureString securePwd = new System.Security.SecureString();
foreach (char c in password)
{
// Append the character to the password.
securePwd.AppendChar(c);
}
Process.Start("notepad", "username", securePwd, "domain");
I'm going to ask a separate question on this. Thanks for all who replied.
精彩评论