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

时间:2013-11-24 17:03:12

标签: vb6

如何在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

我如何作为管理员权限运行命令。

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:-1)

Shell“C:\ Windows \ System32 \ cmd.exe / c”& sYourCommand,vbMaximized