X-Ecutioner Posted June 27, 2004 Share Posted June 27, 2004 ok. I made a front-end loader for my AIO/software DVD. By using javascript, I am able to launch a file through my HTA application which executes a file - which installs a program. (for those of you who think it will allow u to hack into someones pc through the internet...think again. antivirus/firewalls will notify the user of the script. I just simply allow the script because its a local script made by me and I know its safe.) I want to be able to launch this HTA program from a network share for my laptop because my laptop cannot read dvd-rw's. I was wondering if anyone knows how to do it. I have tried many different methods but have had no luck. The posted code is a snippet from one of my many files. BTW. the share path is //server/dvd.<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><link rel="stylesheet" type="text/css" href="./common/wpi.css" /></head><body class="body"><script>function Launchgarminmetro() { var ws = new ActiveXObject("WScript.Shell"); ws.Exec("..\\Garmin\\Canada.Metroguide-RR\\Setup.exe")}function Launchgarminwater() { var ws = new ActiveXObject("WScript.Shell"); ws.Exec("..\\Garmin\\US.Waterways.and.Lights\\Setup.exe")}function Launchgarminmap() { var ws = new ActiveXObject("WScript.Shell"); ws.Exec("..\\Garmin\\World.Map.v3.00\\Setup.exe")}function Launchofficexp() { var ws = new ActiveXObject("WScript.Shell"); ws.Exec("..\\officexp\\SETUPPLS.EXE")}function Launchcamedia() { var ws = new ActiveXObject("WScript.Shell"); ws.Exec("..\\camedia\\camedia\\SETUP.EXE")}function Launchtrips04() { var ws = new ActiveXObject("WScript.Shell"); ws.Exec("..\\Trips04\\cd1run.exe")}function Launchtrips04copyfiles() { var ws = new ActiveXObject("WScript.Shell"); ws.Run("..\\Trips04\\copyfiles.bat")}</script><a name="checks"><form name="WPI"><table width="394" height="256"><tr><td class="txt" valign="top" width="365" height="252"></form><p><font size="3">Microsoft Office XP Professional</font></p><form method="POST" action="--WEBBOT-SELF--"> <input type="button" value="Install" name="B3" onclick="javascript:Launchofficexp()"></p></form><p><font size="3">Microsoft Streets & Trips 2004</font></p><form method="POST" action="--WEBBOT-SELF--"> <input type="button" value="Install" name="B3" onclick="javascript:Launchtrips04()"> <input type="submit" value="Copy Files" name="B1" onclick="javascript:Launchtrips04copyfiles()"></p></form><p><font size="3">Garmin MapSource</font></p><form method="POST" action="--WEBBOT-SELF--"> <input type="button" value="MetroGuide" name="B3" onclick="javascript:Launchgarminmetro()"> <input type="submit" value="Waterways" name="B1" onclick="javascript:Launchgarminwater()"> <input type="reset" value="World Map" name="B2" onclick="javascript:Launchgarminmap()"></p></form><p><font size="3">CaMedia Software</font></p><form method="POST" action="--WEBBOT-SELF--"> <input type="button" value="Install" name="B1" onclick="javascript:Launchcamedia()"></p></form></td></tr></form></table></body></html>Any suggestions or comments would appreciated. Link to comment Share on other sites More sharing options...
Quaternion Posted August 13, 2004 Share Posted August 13, 2004 Try this (This should be all in the HTA file):<HTML><HEAD><script LANGUAGE="JScript">// Localized global variables var L_Setup_Text="Setup Programs From Network"; var L_Office_Text="Microsoft Office XP Professional"; var L_StreetsTrips_Text="Microsoft Streets & Trips 2004"; var L_Garmin_Text="Garmin MapSource"; var L_Camedia_Text="CaMedia Software"; var L_Close_Text="Close";// Set the windows size. var w = 630; var h = 150; window.resizeTo(w, h);// Center the window var e = (w, h); var x = (screen.width-w)/2; var y = (screen.height-h)/2; window.moveTo(x,y);// Launch the selected application. function onClickAppLink(){// Get the path that setup.hta was run from. var sFullPath = unescape(window.parent.location.pathname);// Remove the file name from the full path. var iBackSlash = sFullPath.lastIndexOf("\\"); if (-1 == iBackSlash) return 0;// Set the source folder for this file. var sDir = sFullPath.substring(0, iBackSlash + 1); try { var sApp; var sArg; var sPath; if(32 == event.keyCode) // Source element is the anchor that is the parent of the element to be executed. { sApp = event.srcElement.childNodes(0).app; sArg = event.srcElement.childNodes(0).arg; sPath = event.srcElement.childNodes(0).path; } else // Source element is the element that was clicked. { sApp = event.srcElement.app; sArg = event.srcElement.arg; sPath = event.srcElement.path; } var oShell = new ActiveXObject("Shell.Application"); oShell.ShellExecute(sApp, sArg, sDir+sPath); } catch (oError) { alert("Error : " + oError.Message); } return 0;}// Launch the selected application.function onKeyPressAppLink(){ if (32 == event.keyCode) // Space { onClickAppLink(); }}</SCRIPT><TITLE>DVD Network Install</TITLE><hta:application border="thin" borderstyle="normal" caption="no" icon="Setup.ico" maximizebutton="no" minimizebutton="no" showintaskbar="no" singleinstance="yes" sysmenu="yes" selection="no" scroll="no" version="1.0" windowstate="normal" /></HEAD><body leftmargin="0" topmargin="0" oncontextmenu="return false;" ondragstart="return false;" onselectstart="return false;"><script language="vbscript">Document.Write(L_Setup_Text)</script><li><a target="_blank" HREF="" onclick="onClickAppLink(); return false;" onkeypress="onKeyPressAppLink(); return false;"><b app="/officexp/SETUPPLS.exe" arg="" path=""><script language="vbscript">Document.Write(L_Office_Text)</script></b></a><li><a target="_blank" HREF="" onclick="onClickAppLink(); return false;" onkeypress="onKeyPressAppLink(); return false;"><b app="/Trips04/cd1run.exe" arg="" path=""><script language="vbscript">Document.Write(L_StreetsTrips_Text)</script></b></a><li><a target="_blank" HREF="" onclick="onClickAppLink(); return false;" onkeypress="onKeyPressAppLink(); return false;"><b app="/Garmin/World.Map.v3.00/Setup.exe" arg="" path=""><script language="vbscript">Document.Write(L_Garmin_Text)</script></b></a><li><a target="_blank" HREF="" onclick="onClickAppLink(); return false;" onkeypress="onKeyPressAppLink(); return false;"><b app="/camedia/camedia/Setup.exe" arg="" path=""><script language="vbscript">Document.Write(L_Camedia_Text)</script></b></a><tr><td height=1 align=center><hr></td></tr><tr><td><table border=0 cellpadding=0 cellspacing=0><tr><td width="99%" valign=middle style="font-family: Tahoma, Arial; font-size: 8pt;"></td><td valign="bottom"><button onclick="self.close();" style="background-color: #CCCCCC; border-style: solid; padding-top: 0px; padding-bottom: 0px; padding-right: 6px; padding-left: 6px"><script language="vbscript">Document.Write(L_Close_Text)</script></button></td></tr></table></td></tr></table><td width="16"></td></tr></table></td></tr></table></body></html>As you see you can also use arguments for silent installs and so. Maybe you need to tweak a bit but I know I put you in de right direction. Link to comment Share on other sites More sharing options...
rafael901 Posted October 13, 2011 Share Posted October 13, 2011 I am also having problems running my hta from a network share. When I run it locally, it works just fine. When I try to run it form a network drive only the background and the buttons at the bottom of the script show up. The hta code is below. <HEAD><TITLE>Imaging Application</TITLE><HTA:APPLICATION BORDER = None APPLICATION = Yes WINDOWSTATE = normal INNERBORDER = No SHOWINTASKBAR = Yes SCROLL = No APPLICATIONNAME = "Windows PE Wizard" NAVIGABLE = Yes><!-- external stylesheet --><link rel="stylesheet" type="text/css" href="htaStyle.css" /></HEAD><!****************************************************************************><!* Begin Script ><!****************************************************************************><script Language=VBScript>'****************************************************************************'* Globals'* setup global script parameters'****************************************************************************Option ExplicitDim strTaskValue, objShell, objFso, strBody, objWmiServiceSet objShell = CreateObject("WScript.Shell")Set objFso = CreateObject("Scripting.FileSystemObject")Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2")'****************************************************************************'* Window_OnLoad'* load up behavior and preferences'****************************************************************************Sub Window_Onload self.Focus() strBody = "<H1>CCC Lab Telephony imaging platform</H1>" &_ "<H2>Select Images to apply an OS image using Ghost.<BR><BR>" &_ "Please select an image category:<BR><BR>" enumDirsEnd Sub'****************************************************************************'* enumDirs'* find directories and create category buttons'****************************************************************************Sub enumDirsDim colSubfolders, objFolder, fileName'enumerate folders in images folder Set colSubfolders = objWMIService.ExecQuery _ ("Associators of {Win32_Directory.Name='Z:\imageshare\winpe'} Where AssocClass = Win32_Subdirectory ResultRole = PartComponent")'create html buttons from each folder name For Each objFolder in colSubfolders fileName = objFolder.fileName strBody = strBody &_ "<button id='" & fileName & "' onClick='enumImages("" & fileName & "")'>" & fileName & "</BUTTON>" Next'post resulting html body to document strBody = strBody & "<BR><HR><BR>" body.innerHTML = strBodyEnd Sub'****************************************************************************'* enumImages'* find images and create radio buttons'****************************************************************************'this sub is a little messy because of limitations of win32_shortcutfile and need to go between fso and wmi for different info'also, without the advantages of .net sorting classes, the old bubble sorting is not the funnestSub enumImages(fileName)Dim colFilelist, objFile, strButtons, objShortcut, colTargetList, objTarget, x, y, strKey, strItemReDim arrButtons(1,-1)'reset display element style details.innerHTML = "" details.style.visibility = "hidden"' strButtons = "<table id=buttonTable>"'enumerate ghost image shortcuts in specific images subfolder from enumDirs Set colFileList = objWMIService.ExecQuery _ ("ASSOCIATORS OF {Win32_Directory.Name='z:\imageshare\winpe\" & fileName & "'} Where ResultClass = CIM_DataFile")'find ghost image shortcut targetpath (fso) For each objFile in colFileList If objFile.Extension = "lnk" Then Set objShortcut = objShell.CreateShortcut(objFile.name)'find ghost image shortcut target (wmi) Set colTargetList = objWMIService.ExecQuery _ ("Select * from CIM_Datafile Where name = '" & replace(objShortcut.targetpath,"\","\\") & "'")'add radio button label (from fso) and radio button target (from wmi) to an array For each objTarget in colTargetList ReDim Preserve arrButtons(1,UBound(arrButtons,2)+1) arrButtons(0,UBound(arrButtons,2)) = objShortcut.Description arrButtons(1,UBound(arrButtons,2)) = "<Input type=radio name=radioList id='" & objTarget.Drive & objTarget.Path & objTarget.fileName &_ "' onClick=showRadioInfo>" & objShortcut.Description & "</BUTTON><BR>" Next End If Next'perform a a shell sort of the string array based on button label For x = 0 To UBound(arrButtons,2) - 1 For y = x To UBound(arrButtons,2) If StrComp(arrButtons(0,x),arrButtons(0,y),vbTextCompare) > 0 Then strKey = arrButtons(0,x) strItem = arrButtons(1,x) arrButtons(0,x) = arrButtons(0,y) arrButtons(1,x) = arrButtons(1,y) arrButtons(0,y) = strKey arrButtons(1,y) = strItem End If Next Next'create combined buttons html code from sorted buttons array For x = 0 To UBound(arrButtons,2) strButtons = strButtons & "<tr><td id=buttonTd>" & arrButtons(1,x) & "</td></tr>" Next ' strButtons = strButtons & "</table>"'create a start button with start image command and append and post resulting html to body body.innerHTML = strBody & strButtons & "<BR><HR><BR><button id=start Accesskey=S onclick=doTask(strTaskValue)><U>S</U>tart Image!</BUTTON><BR>" start.style.visibility="hidden"End Sub'****************************************************************************'* doTask'* run task selected by radio button'****************************************************************************Sub doTask(doMe) objShell.Run doMeEnd Sub'****************************************************************************'* showRadioInfo'* display details of radio button selection in details divider'****************************************************************************Sub showRadioInfoDim objTextFile, Radio, strRadioValue, strDetails'set details and start element styles details.style.visibility = "visible" start.style.visibility = "visible"'find checked button For Each Radio in Document.getElementsByName("radioList") If Radio.Checked = True Then'create imaging command line from button id strTaskValue = Chr(34) & "z:\imageshare\ghost\ghost32.exe" & Chr(34) & " -clone,mode=restore,src=" & Chr(34) & Radio.Id & ".gho" & Chr(34) & ",dst=1"'display image details in details element if they exist If objFso.FileExists(Radio.Id & ".htm") Then Set objTextFile = objFso.OpenTextFile(Radio.Id & ".htm", 1) strDetails = objTextFile.ReadAll() Else'display error message in details element if no matching details file found strDetails = "Can't find anything!!!<BR><BR>" &_ "Make sure the info file has the same name as the .gho and has an .htm extension." End If End If Next'post resulting html to details element Details.innerHTML = strDetailsEnd Sub'****************************************************************************'* Reset'* reset the tool interface, also reloads the code (helpful for programming)'****************************************************************************Sub Reset Location.Reload(True)End Sub</Script><!****************************************************************************><!* End Script / Begin HTML ><!****************************************************************************><BODY><DIV id=bg><img src=winpe.bmp></DIV><DIV id=body></DIV><DIV id=details></DIV><DIV id=tools><Button id=ghost onclick=doTask('"z:\imageshare\ghost\ghost32.exe"')>Ghost</BUTTON> <Button id=cmd onclick=doTask('%comspec%')> Cmd </BUTTON> <Button id=notepad onclick=doTask('notepad')> Notepad </BUTTON> <Button id=taskmgr onclick=doTask('taskmgr')> Taskmgr </BUTTON> <Button id=close onclick=self.close()> Quit </BUTTON> <Button id=reset onclick=reset> ResetApp </BUTTON> <Button id=reboot onclick=self.navigate('reboot.hta')> Reboot </BUTTON></DIV></BODY></HTML><!****************************************************************************><!* End HTML ><!****************************************************************************> Link to comment Share on other sites More sharing options...
Tripredacus Posted October 13, 2011 Share Posted October 13, 2011 You realise you bumped a topic from 7 years ago!Did you see my reply? Link to comment Share on other sites More sharing options...
rafael901 Posted October 13, 2011 Share Posted October 13, 2011 I did copy to my winpe image and used the X: drive to call the hta file with no luck. the shortcut image buttons to my hta file will not show up. Only the background and the buttons at the bottom of the file show up. Link to comment Share on other sites More sharing options...
Tripredacus Posted October 14, 2011 Share Posted October 14, 2011 I did copy to my winpe image and used the X: drive to call the hta file with no luck. the shortcut image buttons to my hta file will not show up. Only the background and the buttons at the bottom of the file show up.Copy all files to the ramdisk and launch from the ramdisk. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now