Run As Admin issues

Home Forums Scripting General Scripting Run As Admin issues

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    dmp_92
    Member
    #130162

    Hello,

    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 \beachesNETLOGONKB933360.exe /passive

    Any ideas?

    The code is as follows

    ‘//////////////////////////////////////////////////////////////////////////
    ‘script name: (applicationname)RunAsAtLogOn.vbs
    ‘ first created on 14 march 07 by Remco Simons [nl]
    ‘ (http://forums.petri.com/showthread.php?t=14375)

    ‘ Usage:
    ‘ Run script by users GPO
    ‘ Use the Script-“Parameters-bar”:
    ‘ /u:domainusername /p:password

    ‘ (that way no credentials needed to be stored in the script it self!!!)

    ‘tip: create a special domainUser and make that account member of the
    ‘ ‘local Administrators Group’ by using ‘Restricted groups’ in a GPO
    ‘//////////////////////////////////////////////////////////////////////////

    setupFile = “\beachesNETLOGONKB933360.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”)

    objShell.run(“runas.exe /noprofile /u:” & sUsername & ” “&Chr(34)&””&Chr(34)& _
    “%ProgramFiles%Internet ExplorerIEXPLORE.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
    Wscript.Quit

    ‘NOTE:
    ‘ 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.
    http://www.microsoft.com/technet/sysinternals/utilities/psexec.mspx

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.