添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

How To Run CMD Commands In VB6 As Admin.

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

HOW CAN I RUN THIS COMMAND WITH ADMIN RIGHTS USING CMD.

Dim sYourCommand As String

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

Shell "cmd /c " & sYourCommand, vbMaximizedFocus

HOW CAN I RUN ABOVE COMMAND AS ADMIN privileges.

ShellExecute with "runas" should meet your requirement: ShellExecute 0, "runas", "c:\folder\yourapp.exe", Command & "/admin", vbNullString, SW_SHOWNORMAL rags Nov 25, 2013 at 7:23 If your VB6 programming is running as admin access, any process that is started from it will also run with admin access. You can have your apps run as admin rights by right clicking on the EXE and going into the Compatibility tab and checking the option to run as administrator. vbguyny Feb 2, 2014 at 6:05

Declarations:

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

Code:

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

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

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.