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.
This topic is 13 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
thenoob74
Posts: 17
Last visit: Thu Sep 09, 2010 1:38 am

RunAs using an HTA

Post by thenoob74 »

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
Last visit: Thu Sep 09, 2010 1:38 am

RunAs using an HTA

Post by thenoob74 »

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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

RunAs using an HTA

Post by jvierra »

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
Last visit: Thu Sep 09, 2010 1:38 am

RunAs using an HTA

Post by thenoob74 »

yes that worked! This will work just fine for what I'm doing here. Thanks again for your help!
This topic is 13 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked