dcistech

Member
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

0 Neutral

About dcistech

Profile Information

  • OS
    none specified
  1. There appears to be something wonky going on with the Window_OnLoad, GetWims and ParseFile subs. After adding my animation to the parsefile sub (so people could tell it was working when attempting to get wim info), I noticed it's actually running twice by default--something that's silly, and slows down the HTA. The culprit seems to be a bit of code in the GetWims sub that appears unnecessary. Here is the sub: Sub GetWims(myList()) Dim FSO, strSelectedFolder, strFileList, ObjFile Set FSO = CreateObject("Scripting.FileSystemObject") On Error Resume Next Set strSelectedFolder = FSO.GetFolder(myFilepath) If Err.number <> 0 Then Call Browse() End If Set strFileList = strSelectedFolder.Files For Each objFile in strFileList If Lcase(Right(objFile.Name,4)) = ".wim" Then myList(Ubound(myList)) = objFile.Name Redim Preserve myList(Ubound(myList)+1) End If Next If Ubound(myList)>0 Then Redim Preserve myList(Ubound(myList)-1) End if On Error Goto 0 End Sub The offender comes right after "Set strSelectedFolder = FSO.GetFolder(myFilepath)," and looks like this (since I do not seem to be able to highlight in the code tags): If Err.number <> 0 Then Call Browse() End If The problem is, since GetWims is run automatically on start, the first run will necessarily result in an error (since no wims have been selected) and GetWims will automatically open browse and ask for you to specify a wim. If it stopped there, that would be fine. However, in order for the info browse allows GetWims to pull to show up in the main window, Window_OnLoad has to be run again. So, what you end up with is Window_OnLoad being called from within a sub that was called from Window_OnLoad. And, since Window_OnLoad calls ParseFile, ParseFile (as part of Window_OnLoad) gets run once by GetWims, and then again by the rest of Window_OnLoad. This leads to the HTA taking twice as long as it should to get information from a wim selected when the hta is first opened because the info command gets run twice. So far, the only way I've found to untangle this mess is to remove the error browse call from GetWims. The fact that it's there in the first place is somewhat strange in that browse will only ever let you select a .wim, so the chances of GetWims erring out due to a legitimate error that needs addressing by re-running browse is incredibly unlikely. So ya, if anyone else has an idea that somehow untangles the mess without removing the GetWims error call, I'd love to hear it, but as of now it seems completely unnecessary, and actually slows everything down.
  2. Ok, so I've made a temporary fix barring someone with a more legit idea coming around and sharing it with us. Since the processing HTA can't simply check for the GImageX process, I've "beefed up" the processing subs in the main HTA to create and delete a processing.txt file. The processing HTA then checks for this file--if it exists, it waits five seconds and runs the check again. If the file does not exist, the processing HTA closes. It's roughly equivalent to looking for an elephant by checking for piles of crap, but whatever. It works. If anyone cares, this is what the processing subs look like right at this minute: Sub Start_Processing Set SysFolder = Objfso.GetSpecialFolder(1) objFSO.CreateTextFile(SysFolder & "\processing.txt") objShell.run("processing.hta") End Sub Sub Stop_Processing Set SysFolder = Objfso.GetSpecialFolder(1) objFSO.DeleteFile(SysFolder & "\processing.txt") End Sub Obviously, both subs have to be run for the whole thing to work--the start sub before a given process, the stop sub after a given process. And here's the simple processing HTA: <html> <HEAD> <title>Processing</title> <HTA:APPLICATION BORDER = none APPLICATION = yes WINDOWSTATE = normal INNERBORDER = no SHOWINTASKBAR = no SCROLL = no APPLICATIONNAME = "Processing" NAVIGABLE = yes> </HEAD> <script LANGUAGE="VBScript"> '-------------------------------------------------------------- 'Globals '-------------------------------------------------------------- Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2") Set objFso = CreateObject("Scripting.FileSystemObject") '-------------------------------------------------------------- 'Window_onLoad (Resize and center window) '-------------------------------------------------------------- Sub Window_onLoad strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor") For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight Next intLeft = (intHorizontal - 400) / 2 intTop = (intVertical - 200) / 2 window.resizeTo 400,200 window.moveTo intLeft, intTop End Sub '-------------------------------------------------------------- 'Waiting for GImageX_COM to start the process '-------------------------------------------------------------- idTimer = window.setTimeout("Status_Check", 10000, "VBScript") '-------------------------------------------------------------- 'Check status of operation '-------------------------------------------------------------- Sub Status_Check window.clearTimeout(idTimer) Set objFso = CreateObject("Scripting.FileSystemObject") Set SysFolder = Objfso.GetSpecialFolder(1) If objFso.FileExists(SysFolder & "\processing.txt") Then idTimer = window.setTimeout("Status_Check", 5000, "VBScript") Else Window.Close End If End Sub </SCRIPT> <body background = "pics\processing.gif"> </BODY> </HTML> I'm still planning on having the main HTA create the processing HTA with custom text each time it runs, but for now, I'm leaving it as is, and adding the sub calls before/after all the major processes in the main HTA.
  3. Thanks for the tips. The processing HTA is now set up to check whether a particular process is running, and close if it isn't. I've been testing it with notepad since I wasn't wanting to deal with the main HTA until I knew my processing HTA was working. From what I can tell, the processing HTA works flawlessly. Here it is looking for notepad.exe: <html> <HEAD> <title>Processing</title> <HTA:APPLICATION BORDER = none APPLICATION = yes WINDOWSTATE = normal INNERBORDER = no SHOWINTASKBAR = no SCROLL = no APPLICATIONNAME = "Processing" NAVIGABLE = yes> </HEAD> <script LANGUAGE="VBScript"> '-------------------------------------------------------------- 'Globals '-------------------------------------------------------------- Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2") '-------------------------------------------------------------- 'Window_onLoad (Resize and center window) '-------------------------------------------------------------- Sub Window_onLoad strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor") For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight Next intLeft = (intHorizontal - 400) / 2 intTop = (intVertical - 200) / 2 window.resizeTo 400,200 window.moveTo intLeft, intTop End Sub '-------------------------------------------------------------- 'Waiting for GImageX_COM to start the process '-------------------------------------------------------------- idTimer = window.setTimeout("Status_Check", 10000, "VBScript") '-------------------------------------------------------------- 'Check status of operation '-------------------------------------------------------------- Sub Status_Check window.clearTimeout(idTimer) GImageXStatus = Not Running strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process") For Each objProcess in colProcessList If objProcess.Name = "notepad.exe" Then GImageXStatus = Running End If Next If GImageXStatus = Running Then idTimer = window.setTimeout("Status_Check", 5000, "VBScript") Else Window.Close End If End Sub </SCRIPT> <body background = "pics\processing.gif"> </BODY> </HTML> Basically, I open it, have it wait ten seconds (waiting in an HTA is annoying because wscript.sleep doesn't work), and then have it look for notepad.exe. If it finds it running, it sets an already defined variable to say "running" (it defaults to "not running") and then waits another five seconds before checking again. Once it does not find notepad.exe running, it closes. It's all pretty awesome. One problem: GImageX_COM does not create a separate process for its tasks. They all run under the original mshta.exe. So... ya.
  4. Thanks Tripredacus, apparently I didn't see your post before splitting off here. From my research, it looks like the progress bar code will not work in an HTA because IE stops rendering while the HTA does its thing--hence my attempt to create a pop-up status animation that just lets you know something is happening. My reasoning for making it an HTA rather than a plain .gif (other than the annoying IE frame) being that I eventually want it to display different text depending on the operation--text that could be overlayed onto a generic processing gif. Probably via some sort of create-as-you-go secondary HTA that gets supplied certain variables and then opened. Here is the super simple animation HTA I've put together: <html> <HEAD> <title>Processing</title> <HTA:APPLICATION BORDER = none APPLICATION = yes WINDOWSTATE = normal INNERBORDER = no SHOWINTASKBAR = no SCROLL = no APPLICATIONNAME = "Processing" NAVIGABLE = yes> </HEAD> <script LANGUAGE="VBScript"> Sub Window_onLoad strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor") For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight Next intLeft = (intHorizontal - 400) / 2 intTop = (intVertical - 200) / 2 window.resizeTo 400,200 window.moveTo intLeft, intTop End Sub </SCRIPT> <body background = "pics\processing.gif"> </BODY> </HTML> As you can see, it's nothing at all complicated. In replacing the original status bar bits that aren't working I've done something simple like this: Start_Processing objWIM.ApplyImage End_Processing Start_Processing and End_Processing are both subs I created. My most recent attempt looked like this: Sub Start_Processing Dim processing_hta Set processing_hta = objShell.run("processing.hta") End Sub Sub End_Processing If processing_hta.status = 0 Then processing_hta.Terminate() Set processing_hta = Nothing End Sub The HTA opened, but got somewhat angry when it was then instructed to close. The original progress subs trip mentioned are here: Sub objWIM_Progress(Percent,TimeRemaining) On Error Resume Next objShell.Popup Percent, 1, "Title", -1 If Percent = 100 Then progress.innerHTML = "<table border='0'><tr><td>Percents completed: </td><td>100 % </tr><tr><td>Time remaining: </td><td>0 min 0 sec</td></tr></table>" Exit Sub Else Call ProgressHelper(Percent,TimeRemaining) End If End Sub Sub ProgressHelper(pr,tr) On Error Resume Next intFMin = (tr MOD 3600) \ 60 intFSec = (tr MOD 3600) MOD 60 progress.style.visibility = "visible" progress.innerHTML = "<table border='0'><tr><td>Percents completed: </td><td>" & pr & "%" & "</td></tr><tr><td>Time remaining: </td><td>" & intFMin & " min " & intFSec & " sec</td></tr></table>" If pr = 100 Then window.clearInterval(iTimerID) progress.innerHTML = "<table border='0'><tr><td>Percents completed: </td><td>100 % </tr><tr><td>Time remaining: </td><td>0 min 0 sec</td></tr></table>" Else Exit Sub End If End Sub And the same bit of code I posted that attempts to open and close the progress HTA looks like this in the original: progress.style.visibility = "visible" progress.innerHTML = "<table border='0'><tr><td>Percents completed: </td><td>Calculating</td></tr><tr><td>Time remaining: </td><td>Calculating</td></tr></table>" objWIM.ApplyImage So ya, that's just about everything, aside from looking at the original HTA itself. I can't make heads or tails of the original status bar stuff, and on my end, the gray window trip mentioned is just the after-affect of an earlier HTA being opened and then closed right as the main HTA stops rendering (leaving behind a "shadow" box"). Which make sense if the info I've found is correct and HTA windows stop rendering during tasks.
  5. First off: I'm a bit of a novice. I know enough to make sense of most simple written code (most of the time), but I'm not all that experienced. So, this issue is likely very silly, but I've searched for a solution for a few hours now and can't find one. Anyway, I'm working on modifying an HTA to show a second HTA (with an animation) while the main HTA doing whatever it's doing at the time. However, I'm having trouble getting the new animation HTA to close when the main HTA completes its task. Since the main HTA locks up until it finishes its task, I've tried simply adding an objShell.run before the task and an ObjShell.terminate after the task. However, since it's running from an HTA, the terminate command doesn't seem to want to work, and always throws up an error. I've also attempted switching to a simple animated .gif and using window.open("animated.gif") and window.close("animated.gif"). While that works, the inability to completely remove the border etc is really annoying and not ideal. I have an HTA already made to the specifications I want, I just can't get it to close once its opened. Any ideas?
  6. Alrighty, So I've been tidying up some things in the HTA, and I'm now working on getting a basic animation to display while it's working on whatever its doing. The problem I'm running into is that I can get the super-simple animation HTA window to open, but I'm struggling to get it to close properly. I've tried having it objShell.run(processing.hta) before the main capture/apply/etc operation, and that works great, but objShell.terminate doesn't want to work when the main operation is over (something about HTA limitations maybe?). I've also attempted window.open and window.close, but then I have to direct it to a plain .gif with the stupid IE frame around it. Which is annoying, because eventually I want the text of the processing window to be customized based on the action being performed. Long story short: does anyone know how to get the main .hta to close the other animation .hta? I looked to the other HTAs run by the main one, and they all terminate themselves(window.close). I could even do that if I knew how to check whether the the main .hta was done, but I don't. All these strange limitations to vbscript in an HTA are frustrating.
  7. Tripredacus, thank you for taking the time to reply. I know this all non-standard, and not your script originally, so thanks for taking the time to comment. A quick clarification: when you say it's working in 3.1 x64, do you mean the progress bar as well? As for the cmdcount (cmdpc) business, I've gone ahead and removed it as part of my modifications--I see no point to keeping it in a Win7PE_SE version wherein the circumstances its checking for don't really exist. I'm building a WIN7PE_SE with it removed, and I'll check on functionality to report back to everyone. If I manage to get it all working, I plan to post if for everyone who cares to add it to WIN7PE_SE. I'm guessing my issue was not being able to see the progress bar, as the HTA does appear to have renamed the primary partition of my test machine "system" which it was not named before. The only question then, if the progress bar is working in 3.1 x64, is what I need to do to get it to work in 3.1 x86, or if it's an issue of video drivers/cards. In that case, I may try a few drivers. Depending on what happens with the build of WIN7PE_SE I'm making right now, I'll double check with a normal PE 3.1 and see what happens. It'd still be better than nothing (and far more capable than the old version of this HTA that's currently in use in my organization). I'll edit this post to provide updates hopefully later this afternoon. Thanks again for your help. EDIT: So, good news. The only major issue is the progress display. It applies the images just fine. I'm currently experimenting with using the 6.0 wimgapi.dll (the same .dll called for by the normal GImageX WIN7PE_SE script), the updated GImageX_COM from autoit, and the newest SetRes to see if that somehow changes anything (at the very least, they're more recent versions, meant to play nice with windows 7). I'm also having trouble with the network drive mapping window, in that it displays mostly off screen. I've messed with how it determines "center" to no discernible effect, and I'm turning off a few options in WIN7PE_SE. If that doesn't resolve it, I will try with a standard PE 3.1. Also, the cmdpc/cmdcount stuff was worthless. Nothing that I've seen indicates it's needed--at least in WIN7PE_SE. So, I've removed it.
  8. This seems as good a place as any to post this question, but if I'm in the wrong place, let me know. I'm working on making a WIN7PE_SE script for v7.3 of this HTA. That tends to mean its a bit of a non-standard install, but even with that, I'm getting some strange behavior. Background: I'm currently working with the 32bit version of the HTA/COM. I'm using the package installer script to install the hta, mdac, scripting and wmi packages, and that seems to be working just fine. I currently have the script install everything to the program files folder (ease of shortcuts etc) and have the GImageX_COM.dll set to register on boot. I had some trouble getting that to work, but it's working now. The only modification I've made to the HTA itself was to add the GImageX icon attribute. The Issue(s): When I go to apply an image I run into two issues: first, it tells me I need to have a cmd window open. This is strange to me, as the HTA does not appear to use the cmd window, it just wants it open. I looked at the HTA itself to see if I could figure out the logic behind the cmd count stuff, but it's a bit over my head. Any info as to why it does this, and assuming it is essential, how I might be able to automate it doing this (with the window hidden), would be useful. The second issue, is that even when I make sure to have a cmd window open before running the HTA, I make it all the way to the diskpart settings, select an option (one partition), select the c: drive, and the entire HTA becomes unresponsive. If anyone has any ideas relating to why this might be happening, and how I can resolve it, I would love to hear them. My organization has been using an older PE 2.0 version of the HTA for a while now to help ease imaging computers for techs with little background/time, but I'd like to put together a more robust version with a number of other utilities (hence the WIN7PE_SE set up). Unfortunately, all of that is for nothing if I can't get this HTA to work. EDIT: I should note that the HTA is running from RAM, loaded off a flash drive. I don't think that's related, but ya.