C# ASP.NET Process.start赢得';无法在Windows Server 2012上运行
我正在使用process.start执行schtasks.exe。在我的开发PC(Windows 10)上运行的代码既不能在旧的Windows Server 2012上运行,也不能在Windows 2012生产服务器上运行。我确信这是某种权限问题,但我已经用尽了尝试的方法。我比较了IIS设置和文件管理器权限,但没有发现Windows 10和Windows Server 2012之间有任何不同,这会导致代码仅在服务器上无法工作。我们在事件日志中看到的错误是conhost.exe出错,然后是schtasks.exe出错。计划任务设置为使用具有相应密码的管理员用户运行 下面是在Windows 10上运行但在Windows Server 2012上出现故障的代码C# ASP.NET Process.start赢得';无法在Windows Server 2012上运行,c#,asp.net,windows-server-2012-r2,windows-task-scheduler,C#,Asp.net,Windows Server 2012 R2,Windows Task Scheduler,我正在使用process.start执行schtasks.exe。在我的开发PC(Windows 10)上运行的代码既不能在旧的Windows Server 2012上运行,也不能在Windows 2012生产服务器上运行。我确信这是某种权限问题,但我已经用尽了尝试的方法。我比较了IIS设置和文件管理器权限,但没有发现Windows 10和Windows Server 2012之间有任何不同,这会导致代码仅在服务器上无法工作。我们在事件日志中看到的错误是conhost.exe出错,然后是scht
var proc = new Process
{
StartInfo =
{
UseShellExecute = false,
FileName = @"C:\Windows\System32\schtasks.exe",
Arguments = "/run /tn NameOfExistingScheduledTask",
UserName = "AdminUser",
Password = securePass,
RedirectStandardError = true,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
if (!proc.Start())
{
StreamReader myStreamReader = proc.StandardError;
Console.WriteLine(myStreamReader.ReadLine());
Console.WriteLine(proc.StandardOutput.ReadToEnd());
}
proc.WaitForExit();
它可能很挑剔
我想尝试的方式是这样
谢谢你Zounds博士-我真的很感谢你花时间来帮助我。就在今天,我放弃了让它发挥作用。相反,我正在将事件写入Windows事件查看器。我正在使用该事件触发计划任务的开始。有点混乱,但我没有沮丧。我保留了所有的非工作代码,以备将来使用。我会遵守你的建议。希望下一个站在我的立场上的人现在能把你的解决方案放在手边。再次感谢。