Run VBS files as administrator
For example, you must run VBS files as an administrator if the script is to access a system folder. However, the "Execute as" entry is missing in the context menu - Read here how you can still assign the appropriate rights to the file.
Add context menu "Run as administrator" for VBS files
- Upgrade the command for the context menu of VBS files: Call Regedit and go to "HKEY_CLASSES_ROOT \ VBSFile \ Shell".
- Click in the right part of the window and then create the entry "runas" with "Edit | New | Key". Below this, create the "command" key. Select the new subkey on the left and double-click on "Standard" on the right.
- Then type C: \ Windows \ system32 \ WScript.exe "% 1"% * and press Enter.
- Open "Edit | New | String" and name it "IsolatedCommand". Assign the value C: \ Windows \ system32 \ WScript.exe "% 1"% *.
- After closing the registry, the command "Run as administrator" is now available in the context menu for VBS files.
- If this command is defined for a file type, you can also run it from self-written scripts. To do this, create a file with the following content: Set objShell = CreateObject ("Shell.Application") Set objFolder = objShell.Namespace ("C: \") Set objFolderItem = objFolder.ParseName ("example.vbs") objFolderItem.InvokeVerb "runas" Save the file as "adminstart.vbs". In the future, just double-click on it to start the desired script "example.vbs" with extended rights - you save yourself the hassle of using the menu.
- Note: Security remains intact because the script is only used to call up commands. Windows also prompts for the administrator password via user account control before it actually executes the script.