Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement account Control with VBS and UAC

Shulou Source: shulou.com Published: 2022-06-03 06:52:59 10月02日 Update

This article mainly introduces VBS and UAC how to achieve account control, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Although many people think this feature is a chicken rib, from VBS's point of view, UAC is more or less useful. Under the restriction of UAC, double-clicking the VBS file directly can only run under standard user permissions, and many things cannot be done, such as copying itself to the windows folder, or writing the boot key to the registry, and so on. Storm No. 1 virus, which is very rampant under XP, can only change the folder properties to hidden under Win7, and nothing else can be done. Of course, some students who don't know the truth like to turn off the UAC function and install the so-called security software called 359 or 361. I don't say much either, or I'll be surrounded.

Double-click the VBS file system will not automatically pop up UAC window is a big problem, because this greatly limits the function of VBS, a lot of things can not be done, how to solve it? Please look at the following code

The code is as follows:

For Each objOS in GetObject ("winmgmts:") InstancesOf ("Win32_OperatingSystem")

If InStr (objOS.Caption, "XP") = 0 Then

If WScript.Arguments.length = 0 Then

Dim objShell

Set objShell = CreateObject ("Shell.Application")

ObjShell.ShellExecute "wscript.exe", Chr (34) & _

WScript.ScriptFullName & Chr (34) & "uac", "runas", 1

Else

Call Main ()

End If

Else

Call Main ()

End If

Next

Sub Main ()

MsgBox "UAC demon"

End Sub

I rewrote this according to the code of this website to judge the system version. If it is XP (ordinary users are usually XP, if it is 2003, please rewrite it yourself), then run the code directly, otherwise, call the ShellExecute method of the Shell.Application object to run the script with administrator privileges. In this way, our VBS program can do whatever it wants in Vista/Win7 as it does in XP.

Thank you for reading this article carefully. I hope the article "how to achieve account Control with VBS and UAC" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Code files articles systems functions runs accounts controls things folders permissions users or restrictions large ordinary rampant do whatever you want bad value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Information NVidia Linux Docker