Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vb.net启动进程作为不同用户Excel 2013文档作为ListView的参数-文件已锁定_Excel_Vb.net_Listview - Fatal编程技术网

vb.net启动进程作为不同用户Excel 2013文档作为ListView的参数-文件已锁定

vb.net启动进程作为不同用户Excel 2013文档作为ListView的参数-文件已锁定,excel,vb.net,listview,Excel,Vb.net,Listview,我正在创建一个小应用程序来“作为不同的用户运行”。应打开的文件(完整路径)存储在Listview中 如果调用该过程,请使用 Do_RunAs(“C:\ProgramFiles(x86)\Microsoft Office\Office15\EXCEL.EXE”,“D:\RunAs Test\Naming-Test.xlsx”) ... 它正在工作 但是 如果调用该过程,请使用 调用Do\u RunAs(“C:\Program Files(x86)\Microsoft Office\Office15

我正在创建一个小应用程序来“作为不同的用户运行”。应打开的文件(完整路径)存储在Listview中

如果调用该过程,请使用 Do_RunAs(“C:\ProgramFiles(x86)\Microsoft Office\Office15\EXCEL.EXE”,“D:\RunAs Test\Naming-Test.xlsx”) ... 它正在工作

但是 如果调用该过程,请使用 调用Do\u RunAs(“C:\Program Files(x86)\Microsoft Office\Office15\EXCEL.EXE”,item.SubItems(1.Text) 我在EXCEL中收到此消息(参见链接图片)

下面是Do_RunAs的代码

Public Sub Do_RunAs(strApplication As String, strFilename As String)
    Dim procStartInfo As New ProcessStartInfo
    Dim procExecuting As New Process

    With procStartInfo
        .UseShellExecute = False

        .Domain = strDomain
        .UserName = strUserName
        .Password = ConvertToSecureString(strPassword)
        .Verb = "runas"
        .LoadUserProfile = True

        .FileName = GetShortPathName(strApplication)
        .Arguments = GetShortPathName(strFilename).ToString
        .WindowStyle = ProcessWindowStyle.Normal
    End With

    procExecuting = Process.Start(procStartInfo)
    procExecuting.Close()
End Sub
我已经试过了

  • .Arguments=strFilename
  • .Arguments=Chr(34)+strFilename+Chr(34)
  • .Arguments=GetShortPathName(strFilename)
  • .Arguments=GetShortPathName(strFilename).ToString
什么都不起作用,总是一样的错误


如果有人能帮助我,那就太好了——提前多谢了

我找到了那个问题的答案。。。也许有人需要它 在For Next循环中调用了此Sub。我只是在下次调用这个Sub之前添加了一个WAIT函数

For i = 1 To 10
    Call Do_RunAs("Excel.exe", "xy.xls")
    Wait(3) 'wait 3 seconds
Next
这就解决了问题