Friday, June 6, 2008

How to Run VBScripts as Administrator in Windows Vista

Some programmers are asking why their Restore Point Creator Program written in Vb.Net/C# doesn't work in Windows Vista. It will not work because of UAC. To run the program, you must open or launched it as administrator.

The same way with VB Script programming in Windows Vista. I wrote a simple alternative way to launch scripts as Administrator.

Here:

If WScript.Arguments.Count > 0 Then

'Your VB Script CODE here

Else

Set objLaunch = CreateObject("Shell.Application")
obj
Launch.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " RunAsAdmin", , "runas", 1

End If

It will elevate the script before launching your code.

Read more: Universal Script Template in Elevating Commands as Administrator in Windows Vista

Easy? Enjoy!

More Articles:

How to Get the Windows Experience Index (WEI) score of a Network Computer

Desktop Window Manager Command list

YouTube Hack!

No comments:

Post a Comment