Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run program from logon script as admin?

Status
Not open for further replies.

Tony414

MIS
Feb 3, 2003
197
US
Hello,
I'm sure this has been talked about many times before. I searched the threads but can't pin point what I'm looking for. I was to be able to run a program from a logon script using admin credentials. I know the runas command doesn't allow this. Is there a way for me to do this?

Thanks,
Tony
 
I was to be able to run a program from a logon script using admin credentials

Did you mean to say you want to run a program from a logon script using admin credentials?

Have you checked in your GPO to use elevated permissions for login scripts?

Some options for scripting RunAs permissions:
I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Yes I did. Wow! I really typod that. Unfortunetly I can't do that on machines that still log in on my NT domain. Or can I?
 
That's the problem. The command line utility doesn't allow you to put a password in in a script. If it does, I don't know how...

Tony
 
I think this is what you are looking for. Works great. Also i suggest encoding this file... if you are the only one that will be using it I then suggest window EFS (Encryption file system). This will only work if you have the same local admin name and user password on every machine.. ~~~~~

Code:
Option explicit 

Dim oShell 

set oShell= Wscript.CreateObject("WScript.Shell")

'Replace the path with the program you wish to run c:\program files...

oShell.Run "runas /noprofile /user:administrator ""wscript.exe C:\test.vbs"""

WScript.Sleep 1000

oShell.Sendkeys "passwordhere"
WScript.Sleep 1500
oShell.Sendkeys "{ENTER}"

Wscript.Quit

I hope this helps you out

Focus : )
 
I want to point out that Encoding a file does not Encrypt a file and leaving a password for the admin ID in a script is not a wise decision.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top