Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Running a script as administrator


Recommended Posts

Posted

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 :)

Posted

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

vbsencoder.rar

  • Thanks 2
Posted

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.EXE -Register"""

strUser="[email protected]"

strPass="adminpassword"

set WshShell=CreateObject("WScript.Shell")

WshShell.Run "runas.exe" & " /user:" & strUser & " " & strCmd

WScript.Sleep 1500

WshShell.Sendkeys strPass & "~"

  • Thanks 1
Posted
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! :D

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...