使用用户mssqlserver在C#中启动过程返回NULL

问题描述

我有一个sqlserver 2016数据库。我正在运行一个存储过程,在这里我将其称为DLL程序集。在此程序集中,我正在执行System.Diagnostics.Process.Start来打印PDF。我在本地计算机上拥有了所有东西(SAP B1,sqlServer 2016和Adobe Reader)。一切都很好。但是在我的Windows Server 2016中,System.Diagnostics.Process.Start返回NULL。

当我从SAP B1添加数据时,sqlserver 2016执行我的存储过程并启动打印过程。

数据库启动此操作时,它使用的是NT SERVICE / MSsqlSERVER的用户。我认为该用户无法执行此操作。我检查了pdf文件和打印机的权限。

我认为缺少一些代码。我检查了这个社区,寻找解决方案,但是...

System.Diagnostics.Process printer = new System.Diagnostics.Process();

printer.StartInfo.Arguments = "\"" + impresora + "\""; //impresora seleccionada
printer.StartInfo.FileName = ruta + albaran + ".PDF";
printer.StartInfo.UseShellExecute = true;
printer.StartInfo.Verb = "PrintTo";
printer.StartInfo.CreateNowindow = false;
printer.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

if (System.Diagnostics.Process.Start(printer.StartInfo) == null)
    sqlContext.Pipe.Send("Process is not launched");

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)