Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - RunOnce as Administrator in Vista

Reply
 
Old 05-13-2009   #1 (permalink)
OldDog


 
 

RunOnce as Administrator in Vista

Hi,

I am trying to figure out how to run a vbScript in Vista that requires
Administrators access and then reboot and continue with the script.

In the past, I have used the runonce key in the registry to do this.
However, in Vista, even though I log in as an administrator, the
script does not run.

Any ideas. I saw that this question was asked way back in 2007 but
never answered.


TIA,

OldDog

My System SpecsSystem Spec
Old 05-13-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: RunOnce as Administrator in Vista


"OldDog" <mikef2691@xxxxxx> wrote in message
news:e2453f30-44c0-4371-ae59-64764bfdc8d8@xxxxxx
Quote:

> Hi,
>
> I am trying to figure out how to run a vbScript in Vista that requires
> Administrators access and then reboot and continue with the script.
>
> In the past, I have used the runonce key in the registry to do this.
> However, in Vista, even though I log in as an administrator, the
> script does not run.
>
> Any ideas. I saw that this question was asked way back in 2007 but
> never answered.
>
>
> TIA,
>
> OldDog
The first script (the one that writes to the RunOnce registry key) must run
with Administrator privileges. However, in Vista being logged in as
Administrator is not enough. You must use the "Run as administrator" feature
when you launch the script. For example, you can right click a shortcut to
cmd.exe and select "Run as administrator" and launch the VBScript program in
the elevated command console. The person that logs on after the restart must
be an administrator.

You can right click a *.exe file and select "Run as administrator", but this
option is not available for *.vbs files. I think you must right click either
cmd.exe or a shortcut to cmd.exe to run a VBScript program with enough
privileges to write to HKLM.

If this doesn't work, you may need a manifest.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 05-14-2009   #3 (permalink)
PaulM


 
 

Re: RunOnce as Administrator in Vista

Enter this code in the beginning of your script.

If WScript.Arguments.Count = 0 Then
Set ObjShell = CreateObject("Shell.Application")
ObjShell.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" & " RunAsAdmin", , "runas", 1
Else

--
Windows XP and Vista Tweaks
------------------------------------------------------------
www.paulsxp.com
------------------------------------------------------------
Windows XP and Vista Help Forum
------------------------------------------------------------
www.paulsxp.com/forum
------------------------------------------------------------
Live Computer Help and Chat
------------------------------------------------------------
www.paulsxp.com/livesupport.html
------------------------------------------------------------


"OldDog" <mikef2691@xxxxxx> wrote in message
news:e2453f30-44c0-4371-ae59-64764bfdc8d8@xxxxxx
Quote:

> Hi,
>
> I am trying to figure out how to run a vbScript in Vista that requires
> Administrators access and then reboot and continue with the script.
>
> In the past, I have used the runonce key in the registry to do this.
> However, in Vista, even though I log in as an administrator, the
> script does not run.
>
> Any ideas. I saw that this question was asked way back in 2007 but
> never answered.
>
>
> TIA,
>
> OldDog
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
RunOnce tasks in Vista must be completed before desktop is available? General Discussion
Set-ExecutionPolicy in RunOnce doesn't work PowerShell
setting batchfile to runonce prior to user logon (winxp sp2) PowerShell
Invoking PS script in RunOnce PowerShell
IE 7 Runonce Operation Aborted and other errors. Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46