c#使用process.start启动程序报错解决方法
时间:2021-07-28 01:20:20
出错信息:
Unknown error (0xffffffff)
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName, String arguments)
at ProcessStart.Form1.start()
[/code}
出错情景:
我们发现大多数情况下,C#调用Process.Start根本不会出错。这个错误通常出现在当你使用Local System帐号运行程序时,例如我们有一个windows服务,此服务调用Process.Start创建新进程时,新进程及其所有的子进程都是以System帐号运行的。这时调用Process.Start就有可能出现此错误,只是有可能,其实在我们那么多机器上只有一台运行windows 2003的服务器出现了这个错误。可能与系统设置有关,深层原因有待考察。
解决方法:
只要修改代码,设置ProcessStartInfo的UseShellExecute=false即可
[code]
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = exepath;
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
Process.Start(psi);
标签:process.start,启动程序报错
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Spring源码解析之编程式事务
2023-06-20 19:17:49
![](https://img.aspxhome.com/file/2023/2/57402_0s.png)
解决IDEA springboot"spring-boot-maven-plugin"报红问题
2023-08-15 21:29:19
![](https://img.aspxhome.com/file/2023/3/72543_0s.png)
Java 数据结构与算法系列精讲之哈希算法实现
2022-01-10 23:56:07
![](https://img.aspxhome.com/file/2023/3/71683_0s.gif)
java中treemap和treeset实现红黑树
2021-12-05 07:22:29
![](https://img.aspxhome.com/file/2023/3/73043_0s.png)
浅谈JavaWeb中的web.xml配置部署描述符文件
2023-11-12 00:14:13
java使用淘宝API读写json实现手机归属地查询功能代码
2021-05-31 03:27:38
Maven如何打入依赖中指定的部分jar包
2023-09-22 02:50:33
java动态线程池的简单实现思路
2023-10-18 15:53:46
java 多态性详解及常见面试题
2023-03-15 18:08:49
Spring boot配置文件加解密详解
2023-11-12 00:17:29
![](https://img.aspxhome.com/file/2023/3/59583_0s.jpg)
关于Mybatis-Plus Update更新策略问题
2022-04-14 19:29:24
![](https://img.aspxhome.com/file/2023/6/61276_0s.jpg)
Springcloud seata分布式事务实现代码解析
2022-12-27 20:14:01
![](https://img.aspxhome.com/file/2023/0/66050_0s.png)
Spring主配置文件(applicationContext.xml) 导入约束详解
2021-09-29 06:21:01
![](https://img.aspxhome.com/file/2023/2/69922_0s.png)
springBoot之如何获取接口请求数据和返回数据实现日志
2023-11-23 10:43:58
浅析Mybatis 在CS程序中的应用
2023-06-24 08:44:15
![](https://img.aspxhome.com/file/2023/2/57422_0s.jpg)
Scala中的mkString的具体使用方法
2023-11-16 00:18:18
详解在Spring Boot中使用JPA
2022-08-03 15:44:13
![](https://img.aspxhome.com/file/2023/9/69309_0s.png)
Java日常练习题,每天进步一点点(2)
2023-08-17 22:46:19
![](https://img.aspxhome.com/file/2023/5/63025_0s.png)
Java Socket实现传输压缩对象的方法示例
2022-12-18 06:52:30
Java实战之用hutool-db实现多数据源配置
2023-11-28 19:37:10
![](https://img.aspxhome.com/file/2023/0/60250_0s.png)