如何以管理员身份在 Vb6 中运行 CMD 命令

问题描述 投票:0回答:2

如何以管理员身份在 VB6 中运行 CMD 命令。

netsh wlan set hostednetwork mode=allow ssid="admin" key="admin"

如何使用 CMD 以管理员权限运行此命令。

Dim sYourCommand As String

sYourCommand = "netsh wlan set hostednetwork mode=allow ssid="admin" key="admin""

Shell "cmd /c " & sYourCommand, vbMaximizedFocus

我如何以管理员权限运行以上命令。

vb6
2个回答
0
投票

声明:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

代码:

ShellExecute 0, "runas", "c:\folder\yourapp.exe", Parameter, vbNullString, SW_SHOWNORMAL

来源:https://www.vbforums.com/showthread.php?608723-RESOLVED-Run-as-administrator-automatically


-2
投票

Shell“C:\Windows\System3

© www.soinside.com 2019 - 2024. All rights reserved.