RunAs using an HTA

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

RunAs using an HTA

Post by thenoob74 » Tue Sep 07, 2010 11:46 pm

Hello,I'm looking for some assistance with using an HTA form to launch another hta file as a Domain administrator. (domainusername) any ideas or maybe a best practice for this type of situation where an hta file needs admin rights to run?uploads/34385/runas.txtI don't think my attachment came through so I'm going to paste my code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- ... dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>TSM POST SETUP</title></head><script language="vbscript">Sub send_onclick()on error resume next sPSExec = "psexec /accepteula -u " & sUserID & " -p " & sUserPassword & " " & "" sCmd = sPSExec & "cscript.exe filestest4.hta" Set oShell = CreateObject("WScript.Shell") oShell.run sCmdend sub</script><body><body style="background-color: #EF0000"> Type you AX Account<br /> <Input type=text name="sUserID" tabindex=1 size="20"><br> Type your Password (AX Account) <br /> <Input type=password name="sUserPassword" tabindex=1 size="20"> <br /> <br /><input name="Button1" type="button" value="Login" /></body></html>

User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

RunAs using an HTA

Post by thenoob74 » Wed Sep 08, 2010 3:29 am

Yes running as the admin works, however if another tech needs to run this they would have to edit the batch file and remove the name and add theirs. I'll try the above with an hta form and see if I'm able to do it using runas. last time I attempted it threw an error back saying that the hta file was an invalid win32 application. But when I used your runas line it worked with my credentials, I'll see what I can do with an HTA form.

User avatar
jvierra
Posts: 13292
Joined: Tue May 22, 2007 9:57 am
Contact:

RunAs using an HTA

Post by jvierra » Wed Sep 08, 2010 7:11 am

THe following:

Code: Select all

	
WshShell.Exec "RunAs /u:" & user & " &  " ""cmd /c c:testmyhta.hta"""
	
Works fine for me.
jvierra2010-09-08 14:33:15

User avatar
thenoob74
Posts: 17
Joined: Tue Aug 10, 2010 1:55 am

RunAs using an HTA

Post by thenoob74 » Thu Sep 09, 2010 1:38 am

yes that worked! This will work just fine for what I'm doing here. Thanks again for your help!

Locked