Please Read: Significant Update Planned, Migrating Forum Software This Month

See more
See less

Run As Admin issues

  • Filter
  • Time
  • Show
Clear All
new posts

  • Run As Admin issues


    I have found exactly what I was looking for on this form. Thread name "Run As" batch file to install software as domain admin.

    When I impliment this with GP as stated in the document, I receive an error on the test workstation stating it can not find the path. The path I have entered below on the setup file is proper and does work, however when I run this on the test workstation using this script it gives me an error message stating that it can not find the file. I have notice that when the error comes up on the test computer it shows the switches backwards.

    EG. //beaches/NETLOGON/KB933360.exe /passive

    It should be \\beaches\NETLOGON\KB933360.exe /passive

    Any ideas?

    The code is as follows

    'script name: (applicationname)RunAsAtLogOn.vbs
    ' first created on 14 march 07 by Remco Simons [nl]
    ' (
    ' Usage:
    ' Run script by users GPO
    ' Use the Script-"Parameters-bar":
    ' /u:domain\username /password
    ' (that way no credentials needed to be stored in the script it self!!!)
    'tip: create a special domain\User and make that account member of the
    ' 'local Administrators Group' by using 'Restricted groups' in a GPO

    setupFile = "\\beaches\NETLOGON\KB933360.exe /passive" '<-----application to runas [!]

    'Read arguments...
    sUsername = Null
    sPassword = Null
    Set Named = WScript.Arguments.Named
    If Named.Exists("u") Then sUsername = Named.Item("u")
    If Named.Exists("p") Then sPassword = Named.Item("p")

    set objShell = CreateObject("Wscript.Shell")"runas.exe /noprofile /u:" & sUsername & " "&Chr(34)&"\"&Chr(34)& _
    "%ProgramFiles%\Internet Explorer\IEXPLORE.EXE\" &Chr(34)& _
    " -e \"&chr(34) & setupFile & "\"&Chr(34)&Chr(34))

    WScript.Sleep 600 '<----must be the max. amount of second it takes to to open the Runas: "enter password" window

    objShell.AppActivate "runas.exe"
    If objShell.AppActivate("runas.exe") then _
    objShell.Sendkeys sPassword&"~" '<--- auto fill-in the password, and continues

    set objShell = Nothing

    ' This script use microsoft's "RunAs" tool.
    ' With this tool you cannot add password on commandline,
    ' therefore a "sentkeys" option is used to fillin the password.
    ' If this is unstable, alternatively you can use PsExec.exe instead.

  • #2
    Re: Run As Admin issues

    The -e switch did only work for IE6 and earlier, but is does not function for IE7.

    The next reply in the thread where this script was published, I explaned that when you want to execute just one file, you don't need to open a file-browser with alternate credentials, just execute the file directly using RunAs (or by using psExec.exe).
    Code:"runas.exe /noprofile /u:" & sUsername & " "&Chr(34)&"\"&Chr(34)& _ 
                 setupFile &"\" &Chr(34)&Chr(34))
    And.. do read the notes in every reply there, that it is not recommended to store accountname and password of administrator accounts in plain textfiles! It is just not secure.

    Instead, You best can install the update with a computer Startup/Shutdown script. Then there are no alternate credentials needed for installation (to see the available installation options for this updatefile, run the updatefile with the /Help switch).

    - what is the OS and servicepack level of these computers?


    This posting is provided "AS IS" with no warranties, and confers no rights.


    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts