惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - Ticky

关于WCF的“调用方未由服务进行身份验证”的另一解决方法 [转]ASP.NET页面事件:顺序与回传详解 [转]Dynamic ListView LayoutTemplate [转]多层C/S系统及其在PB中的应用 .NET强命名设置随笔 - Ticky - 博客园 [转载]SQL Server阻塞详解 Chrome发布了,感受新体验 绝对经典的十个故事 SQL SERVER的一些常用查询语句收集 链接服务器的服务器连接问题 存储过程参数的时间默认值解决方法 别把捐款与善心划等号 [转]ORM的介绍 工作随记 [转]Windows Communication Foundation介绍(四) [转]Windows Communication Foundation介绍(三) [转]Windows Communication Foundation介绍(二) [转]Windows Communication Foundation介绍(一) Microsoft OneNote 2007的体验
Process.Start触发Enviroment的改变
Ticky · 2011-11-04 · via 博客园 - Ticky

一直以为Process.Start("文件路径")后,这个文件的运行就会脱离当前程序环境,以前用了很多次,也一直这样认为。

今天刚好碰到一个程序,也是要用Process.Start的,但却不成功,很苦恼。

在通过反编译一步步跟踪程序后,锁定了“System.Environment.CurrentDirectory”。估计应该是虽然运行新程序,但Environment却没有改变,仍然保持了当前状态,我尝试着将两个程序放在同一目录下,果然成功了!

问题找到了,原因也知道,接下来就是纠正。以下就是示例:

var info=new System.Diagnostics.ProcessStartInfo("文件路径");
info.UseShellExecute = true;
info.WorkingDirectory= "文件目录";          

System.Diagnostics.Process.Start(info);

为新调用的程序创建一个新的进程实例,同时指定程序的文件目录,从而改变Environment状态。