View Single Post
  #12 (permalink)  
Old December 8th, 2011, 12:47 PM
vikingMoJo vikingMoJo is offline
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Dec 2011
Location: Oregon
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Running it from an .HTA

These are some good examples here. Thanks for sharing them. I tried running the example from Inforequester from within an hta in an effort to learn more about scripting. The code produces the following error: Object required 'Wscript' . I tinkered with it for over an hour to get that error cleared to no avail. This little program/script launches Notepad and IE as expected but that's all it does.

Question # 1: Why is it producing that error?

Below is my source code:


<script language="VBScript">

    Sub RunProgram1 
        Set objShell = CreateObject("WScript.Shell")
        objShell.Run "notepad.exe C:\Documents and Settings\UsersName\My Documents\First_HTA_Automation_Script\ReadMe.txt"
    End Sub

    Sub RunProgram2 

	Set IE = CreateObject("InternetExplorer.Application") 
	set WshShell = CreateObject("WScript.Shell")  
	IE.Navigate "" 
	IE.Visible = True 
	WScript.Sleep 6000
	IE.Document.All.Item("fld_userName").Value =         ""
 	IE.Document.All.Item("fld_password").Value = "superPassword" 
	WshShell.AppActivate "IE" 
	WshShell.SendKeys "{ENTER}"
    End Sub


<button onclick="RunProgram1">Launch Notepad</button> <p>
<button onclick="RunProgram2">Launch IE</button> <p>
Question # 2: Can anybody direct me to some good online tutorials for using VBscripts from HTA's (Hypertext Applications) ??

My ultimate goal with VBscript is to automate the testing and routine tasks that I have to do with web browsers and I would like to house and launch my VBscripts from HTA's.

THANK YOU in advance.
Reply With Quote