+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, Running a script as administrator in Coding and Web Development; I want a script that'll force another script to run with account credentials i specify but i want it to ...
  1. #1
    mrbios's Avatar
    Join Date
    Jun 2007
    Location
    Stroud, Gloucestershire
    Posts
    2,449
    Thank Post
    349
    Thanked 255 Times in 210 Posts
    Rep Power
    98

    Running a script as administrator

    I want a script that'll force another script to run with account credentials i specify but i want it to be secure so no one can see the password from it while it's running

    basically what im aiming to do is give teachers the ability to restart the print spooler service which they can't do under their accounts, i've got my net stop spooler net start spooler bit in a batch file, but i need something that'll run that script as an administrator.

    I know that in a batch file i can do runas /user:domain\user but this asks me for the password and it's not secure even if it did let me put the password in.

    Thanks for any help on this

  2. #2
    box_l's Avatar
    Join Date
    May 2007
    Location
    Herefordshire
    Posts
    427
    Thank Post
    68
    Thanked 90 Times in 75 Posts
    Rep Power
    61
    Hi,

    This is how I do it.

    See attached .rar file

    It contains a runas .vbs and a way to use screnc to encode them.

    encoded files are placed in the "encoded" folder as .vbe.

    Windows will execute them as if the were .vbs.

    They can be decrypted, but a user will have to have a reasonable bit of knowledge to do it.

    BoX
    Attached Files Attached Files

  3. 2 Thanks to box_l:

    Gibbo (23rd September 2010), mrbios (23rd September 2010)

  4. #3
    mrbios's Avatar
    Join Date
    Jun 2007
    Location
    Stroud, Gloucestershire
    Posts
    2,449
    Thank Post
    349
    Thanked 255 Times in 210 Posts
    Rep Power
    98
    Thank you very much box_l that's even better than i was hoping for

  5. #4

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,060
    Thank Post
    853
    Thanked 2,674 Times in 2,269 Posts
    Blog Entries
    9
    Rep Power
    768
    You could also just assign them the rights to restart the service via GPO and simply have the script run as them. This way there is no possibility of them retriving the password or retasking the rights.

    How To Configure Group Policies to Set Security for System Services

  6. Thanks to SYNACK from:

    mrbios (23rd September 2010)

  7. #5
    Mr.Ben's Avatar
    Join Date
    Jan 2008
    Location
    A Pirate Ship
    Posts
    941
    Thank Post
    182
    Thanked 157 Times in 126 Posts
    Blog Entries
    2
    Rep Power
    65
    Here is how I do it in a vb script... (in this case to register FoxIT as the default pdf viewer)....

    'On Error Resume Next
    strCmd="""C:\PROGRA~1\FOXITS~1\FOXITR~1\FOXITR~1.E XE -Register"""
    strUser="admin@school.local"
    strPass="adminpassword"
    set WshShell=CreateObject("WScript.Shell")
    WshShell.Run "runas.exe" & " /user:" & strUser & " " & strCmd
    WScript.Sleep 1500
    WshShell.Sendkeys strPass & "~"

  8. Thanks to Mr.Ben from:

    mrbios (23rd September 2010)

  9. #6
    mrbios's Avatar
    Join Date
    Jun 2007
    Location
    Stroud, Gloucestershire
    Posts
    2,449
    Thank Post
    349
    Thanked 255 Times in 210 Posts
    Rep Power
    98
    Thanks guys, synack i must be being simple today, normally things like that pop straight into my head, thank you very much i think i'll use that route!

SHARE:
+ Post New Thread

Similar Threads

  1. Login Script not running
    By adamf in forum Windows Server 2000/2003
    Replies: 8
    Last Post: 12th August 2009, 09:59 PM
  2. Replies: 21
    Last Post: 27th February 2009, 01:08 PM
  3. VBS Drive script is running from
    By Samson in forum Scripts
    Replies: 5
    Last Post: 10th May 2007, 03:29 PM
  4. Run Script as Administrator
    By TSCNUK in forum Windows
    Replies: 8
    Last Post: 20th November 2006, 04:20 PM
  5. Replies: 8
    Last Post: 12th November 2006, 02:02 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •