启动Windows进程 [英] Starting a Windows Process

查看:72
本文介绍了启动Windows进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是非常标准的代码,为Current.File执行关联的应用程序并继续加载.

This is pretty standard code that executes the associated application for Current.File and goes on to load it.

Private Sub StartProcess()
   With omProcess
      .StartInfo.FileName = Current.File
      .EnableRaisingEvents = True
      Try
         .Start()
      Catch ex As Exception
         ShowMsg(ex.Message)
      End Try
   End With
End Sub



但是,在加载AutoCad时,工程图仅以只读方式加载,这不是我想要的.

有任何想法吗?



However, when loading AutoCad, the drawing is loaded READ ONLY, which is not what I want.

Any ideas?

推荐答案

只读的AutoCad行为与您显示的代码无关.如果您使用完全相同的参数启动AutoCad应用程序,我相信您会得到相同的行为.假定您最终通过System.Diagnostic.Process开始此过程. (您的omProcess是那种类型吗?如果不是,应该是.)查看StartInfo的所有其他参数.您在哪里将命令行传递给AutoCad?问题可能在那里.

-SA
Read-only AutoCad behavior has nothing to do with the code you show. If your start AutoCad application with exact same parameters, I''m sure you will get identical behavior. In presume you ultimately start this process via System.Diagnostic.Process. (Is your omProcess of that type? If not, it should be.) Look at all other parameters of the StartInfo. Where is you command line passed to AutoCad? The problem is probably there.

—SA


一种可能性是该文件只是只读的.你已经检查过了吗?

如果那不能解决问题,则可以尝试:
-将LoadUserProfile 定义为true
-将RedirectStandardError RedirectStandardOutput都设置为true,并检查两个流是否都从中获取任何信息.
One possibility would be that the file is simply read-only. Have you already checked that?

If that doesn''t solve the problem, you could try to:
- define the LoadUserProfile to true
- set both RedirectStandardError and RedirectStandardOutput to true and check both streams if you get any info from those.


我相信这全都与权限有关.
我正在尝试通过对象模型. Windows帮助并没有真正的帮助.
这就是我要去的地方.
I believe it is all about Permissions.
I am trying to work through the object model. Windows Help is not really helpful.
This is where I have got.
Public Sub New(ByVal User As String, ByVal Domain As String)
   Dim s As New System.Security.Permissions.FileIOPermission(Security.Permissions.PermissionState.Unrestricted)
   s.AllFiles = Security.Permissions.FileIOPermissionAccess.AllAccess
   Dim u As New System.Security.SecureString
   u.Clear()
   omProcess = New System.Diagnostics.Process
   With omProcess
      .EnableRaisingEvents = True
      .StartInfo.Domain = Domain
      .StartInfo.LoadUserProfile = False
      .StartInfo.Password = u
      .StartInfo.StandardErrorEncoding = Nothing
      .StartInfo.StandardOutputEncoding = Nothing
      .StartInfo.UserName = User
      .StartInfo.UseShellExecute = False
   End With
End Sub
Public Sub Launch(ByVal File As String)
   omProcess.StartInfo.FileName = File
   Try
      omProcess.Start()                                                                '  Why Read Only??
   Catch ex As Exception
      Err.Raise(1234, Me, ex.Message)
   End Try
End Sub


我注意到我还没有合并您的代码,此后我已经完成了.但是同样的消息.
我实际上不知道我在做什么.变量s和u只是测试.


I notice that I hadn''t incorporated your code, which I have since done. But same messages.
I don''t actually know what I am doing. Variables s and u are simply tests.


这篇关于启动Windows进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆