“目录名称无效” Process.Start 出错?
我正在编写一个启动程序,当我启动该进程时,出现“目录名称无效”错误。 这是启动该过程的代码:
Const DEBUG_ROOT = _
"Z:\Kiosk_JC\KioskSignIn.root\KioskSignIn\KioskSignIn\KioskSignIn\bin\Debug"
Dim oKiosk As New System.Diagnostics.Process
oKiosk.StartInfo.UserName = oEnc.Decrypt(Username)
oKiosk.StartInfo.Password = oEnc.DecryptSecure(Password)
oKiosk.StartInfo.Domain = oEnc.Decrypt(Domain)
''// The AddBS function appends a '\' to the passed string if it is not present
oKiosk.StartInfo.WorkingDirectory = AddBS(DEBUG_ROOT)
oKiosk.StartInfo.FileName = "KioskSignIn.exe"
oKiosk.StartInfo.UseShellExecute = False
Dim proc As Process = Nothing
proc = System.Diagnostics.Process.Start(oKiosk.StartInfo)
我在这里看到另一个问题,我需要设置工作目录(在我开始搜索之前,我收到了错误)。 即使我设置了此属性,我仍然收到错误。 有什么想法吗?
更多信息
我还应该注意,我的 Z:\ 位于我的网络上。 我有一个函数可以解析 UNC 的路径。 当我在 DEBUG_ROOT 上运行此函数时,出现相同的错误。
我尝试将应用程序移动到 c:\kiosk。 相同的结果。 我以我模拟的用户身份登录,因此我可以访问所有共享和文件。
这是链接,由于某种原因,URL 格式想要消耗指定链接后的所有文本:
I am writing a launcher program, and when I go to start the process I get the "The directory name is invalid" error. Here is the code that is launching the process:
Const DEBUG_ROOT = _
"Z:\Kiosk_JC\KioskSignIn.root\KioskSignIn\KioskSignIn\KioskSignIn\bin\Debug"
Dim oKiosk As New System.Diagnostics.Process
oKiosk.StartInfo.UserName = oEnc.Decrypt(Username)
oKiosk.StartInfo.Password = oEnc.DecryptSecure(Password)
oKiosk.StartInfo.Domain = oEnc.Decrypt(Domain)
''// The AddBS function appends a '\' to the passed string if it is not present
oKiosk.StartInfo.WorkingDirectory = AddBS(DEBUG_ROOT)
oKiosk.StartInfo.FileName = "KioskSignIn.exe"
oKiosk.StartInfo.UseShellExecute = False
Dim proc As Process = Nothing
proc = System.Diagnostics.Process.Start(oKiosk.StartInfo)
I saw on another question here that I needed to set the WorkingDirectory (before I started searching I was getting the error). Even though I have this property set, I am still getting the error. Any thoughts?
More info
I should also note that my Z:\ is a on my network. I have a function that resolves a path to UNC. When I ran this function on DEBUG_ROOT, I get the same error.
I tried moving the application to c:\kiosk. Same result. I am logged in as the user I am impersonating, so I have access to all shares and files.
Here is the link, for some reason the URL formating wants to consume all the text after the link is designated:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
映射驱动器是针对每个用户的。 您可能正在使用不同的用户启动该过程。
Mapped drives are per-user. You are likely starting the process with a different user.
听起来该进程看不到 Z: 驱动器或没有安全访问权限。 应用程序在什么用户上下文中运行? 也许 Z: 驱动器在这种情况下不可用。
Sounds like the process can't see the Z: drive or doesn't have security access. What user context does the app run under? Perhaps the Z: drive is not available in that context.
我得到了和你一样的错误。 您用来运行该进程的用户很可能无权访问指定的资源(exe 文件),
请尝试将您的 exe 移动到其他位置和/或授予您的用户对该文件的访问权限。
I got the same error as you do. most likely the user you use to run the process does not have access to specified resource (exe file)
try to move your exe to some other location and/or give your user access rights to the file.