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

推荐订阅源

K
Kaspersky official blog
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
D
Docker
博客园 - 司徒正美
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
U
Unit 42
J
Java Code Geeks
A
About on SuperTechFans
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
T
Threatpost
H
Hacker News: Front Page
G
Google Developers Blog
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
L
Lohrmann on Cybersecurity
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
A
Arctic Wolf
S
Secure Thoughts
GbyAI
GbyAI
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - 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状态。