启动新进程,而不是生成进程的子进程 [英] Start new process, without being a child of the spawning process
本文介绍了启动新进程,而不是生成进程的子进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果它不是调用进程的子进程,我将如何开始一个新进程.
How would I go about starting a new process without it being the child of the calling process.
示例:
主程序(Caller.exe)
process.start("file.exe")
图片:
推荐答案
这是我现在使用的代码.我认为它可能对某人有用.它接受一个参数.参数是一个 base64 编码的字符串,可解码为您要运行的文件的路径.
Here is the code that I'm now using. I thought that it may be useful to someone. It accepts one argument. The argument is a base64 encoded string that decodes to the path of the file that you would like to run.
Module Module1
Sub Main()
Dim CommandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs
If CommandLineArgs.Count = 1 Then
Try
Dim path As String = FromBase64(CommandLineArgs(0))
Diagnostics.Process.Start(path)
Catch
End Try
End
End If
End Sub
Function FromBase64(ByVal base64 As String) As String
Dim b As Byte() = Convert.FromBase64String(base64)
Return System.Text.Encoding.UTF8.GetString(b)
End Function
End Module
这篇关于启动新进程,而不是生成进程的子进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文