Page 1 of 1

RunAs using an HTA

Posted: Tue Sep 07, 2010 11:46 pm
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>

RunAs using an HTA

Posted: Wed Sep 08, 2010 3:29 am
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.

RunAs using an HTA

Posted: Wed Sep 08, 2010 7:11 am
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

RunAs using an HTA

Posted: Thu Sep 09, 2010 1:38 am
by thenoob74
yes that worked! This will work just fine for what I'm doing here. Thanks again for your help!