Vb.net 以Windows 7和Windows XP管理员身份运行程序
现在我知道您可以执行以下代码,使其在Windows 7中以管理员身份运行Vb.net 以Windows 7和Windows XP管理员身份运行程序,vb.net,Vb.net,现在我知道您可以执行以下代码,使其在Windows 7中以管理员身份运行 Dim myProcess2 As New System.Diagnostics.Process() Dim startInfo2 As New ProcessStartInfo startInfo2.FileName = Application.StartupPath & "\installs\Assistant\RegisterSureFire.exe"
Dim myProcess2 As New System.Diagnostics.Process()
Dim startInfo2 As New ProcessStartInfo
startInfo2.FileName = Application.StartupPath & "\installs\Assistant\RegisterSureFire.exe"
startInfo2.Verb = "runas"
myProcess2.StartInfo = startInfo2
Application.DoEvents()
myProcess2.Start()
但当您在WindowsXP中执行此操作时,会出现一个框,询问您是想在当前用户中还是在管理员中运行它。然后通常我的客户会感到困惑,给我们打电话,然后胡说八道。。。有没有办法让它检测windows版本,如果它低于windows Vista,那么就不要使用“runas”
或者任何其他有用的方法也会很好 您正在寻找。我测试了该代码,它返回了OSVersion:Microsoft Windows NT 6.2.9200.0,它甚至说有时无法返回正确的操作系统。。。。注意:我使用的是Windows8。这似乎对我不起作用,还有其他方法吗?@eqiz:Windows8的实际版本号是WindowsNT6.2。您可以在
winver
命令中看到这一点。XP为5.2;Vista是6.0。