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 14 years and 8 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.
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Popup WSHShell.regread("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsWindows Error ReportingLocalDumpsDumpCount")
But this, saved as .HTA which is basically the same, says root invalid
<script language="VBScript">
Sub window_onload
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Popup WSHShell.regread("HKLMSOFTWAREMicrosoftWindowsWindows ErrorReportingLocalDumpsDumpCount")
End Sub
</script>
The window executes this before it is ready unless you tell it to execute in teh "window_onload" procedure which occurs after teh windows has been built and displayed.
If you don't put the code in the onload procedure it will only work intermittently. Look at teh DHTML and IE/HTA Windows specs. It is very clear that any code short of simple assignment must be plaxced inside of a procedure or an event. If this is not done then the code will fail occasionally. Search MS KB and you willfind numerous examples.
Of course you may have made a typo when translating th first time. I find with IE7 and later on XP that code not in a procedure will normally execute correctly nearly all of the time. On Windows 2003 and on Vista or on a very busy XP system it will fail.
Do yourself a favor by placing code in procedure.
Here is an laternate method that globalizes the object allowing it to be initialized only once.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>My HTML Application</title>
<script language="vbscript">
Dim wshShell, regval
Sub window_onload()
Set WSHShell = CreateObject("WScript.Shell")
regval= WSHShell.regread("HKLMSOFTWAREMicrosoftWindowsWindows Error ReportingLocalDumpsDumpCount")
test.innerHTML = regval
End Sub
</script>
</head>
<body>
<div id="test"></div>
<input type="button" value="GetReg" onclick="MsgBox regval,,'DumpCount'" />
</body>
</html>
You cannot drag and drop from messagebox or popup so I don't know how you expect to accomplish that. You can assign value to display control and copy and paste from there.
I use IE6 at home and IE8 on the machine where it's not working.So I assume there is no workaround with .HTA and the best methodis using a .VBS and create a HTML-file with it for the report?Like VBS => get key, create HTML file with key displayed, open file
Each "onload" method is called in turn. The window_onload is called first then body then each object in body and so on.
You problem is that you are trying to call a popup messagebox. This will stop all processing as soon as it is called. It effectively aborts processing by diverting teh flow of events.
You should run everything in the body onload or run everything in window_onload but use no popups. In Window_onload assign output to a div like in my example.
If you are trying to scatter gather info then you can assign it to controls on body as you get info in onload of windows and/or body.
YOu should not have trouble with CSDVersion but cannot run that code outside of an event or it will not behave correctly.
Hey,I'm now in my office and I try exactly the code you provided and it's not working, same message appears "invalid root".So the onload wasn't the problem, its a security issue probably.Sad that there is no way to produce a layout with vbscriptThanks for your help though
This topic is 14 years and 8 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.