Advertisement
dcandygmailcom

Run a windows' program elevated using a manifest

Feb 10th, 2019
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.33 KB | None | 0 0
  1. REM Three files follow
  2. REM RunAsAdminConsole.bat
  3. REM This file compiles RunAsAdmin.vb to RunAsAdmin.exe using the system VB.NET compiler.
  4. REM Runs a program elevated using a manifest
  5. C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc "%~dp0\RunAsAdmin.vb" /win32manifest:"%~dp0\RunAsAdmin.manifest" /out:"%~dp0\RunAsAdmin.exe" /target:winexe
  6. REM To use
  7. REM RunAsAdmin <Command to run>
  8. pause
  9.  
  10. --------------------------------------------------------------------
  11.  
  12. RunAsAdmin.Manifest
  13.  
  14. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  15. <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  16. <assemblyIdentity
  17.     version="1.0.0.0"
  18.     processorArchitecture="*"
  19.     name="Color Management"
  20.     type="win32"
  21. />
  22. <description>Serenity's Editor</description>
  23. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  24. <security>
  25.     <requestedPrivileges>
  26.         <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
  27.     </requestedPrivileges>
  28. </security>
  29. </trustInfo>
  30.  
  31. </assembly>
  32.  
  33. --------------------------------------------------------------------
  34.  
  35. 'RunAsAdmin.vb
  36. imports System.Runtime.InteropServices
  37. Public Module MyApplication  
  38.     Public Sub Main ()
  39.         Dim wshshell as object
  40.         WshShell = CreateObject("WScript.Shell")
  41.         WshShell.Run(Command())
  42.     End Sub
  43. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement