问题
I have a HTA file that open a text box alows user to enter path to a folder then save it to a text file.
But when I trying to use second button to run a batch, it gives me an error code
Code Error 800A01A8 - Object Required : Wscript
<html>
<head>
<title>Files Sync </title>
<HTA:APPLICATION
APPLICATIONNAME="Files Sync"
ID="RY"
VERSION="1.0"/>
</head>
<script language="vbscript">
Sub WriteTxt_OnClick()
Dim fso, txt
Set fso = CreateObject("Scripting.FileSystemObject")
Set txt = fso.CreateTextFile("\\fs-02\C$\ntfs3\scripts\MexSync\000.txt")
txt.WriteLine document.Submitted_Link_To_Mex.body.value
MsgBox "File Submitted",64,"Selection"
End Sub
Sub SYNC_onClick()
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe /c C:\work\RLTP_SYNC_MEX\RunChangePS1.bat", 0
' 0 => hide
MsgBox("Success")
End Sub
</script>
<H2>Copy And Paste The Folder Path To Here </H2>
<body>
<form name="Submitted_Link_To_Mex">
<textarea name="body" cols="150" rows="20">
</textarea>
</form>
<br>
<input type="button" value="1. SUBMIT" name="WriteTxt">
<input type="Button" value="2. SYNC" name="SYNC">
<input type="Button" value="3. CLOSE" name="button2" onClick="close" class="button">
</div>
</body>
</html>
I can't find out why....did some research but no luck at all Any suggestion?
回答1:
The WScript object your line
Set WshShell = WScript.CreateObject("WScript.Shell")
tries to use does not exist in a HTA (it is provided by the w|cscript.exe hosts). As VBScript (the language itself) provides its own CreateObject function, just use
Set WshShell = CreateObject("WScript.Shell")
回答2:
You need a trailing \
on your replacement text else you have DataAppData
Replace(txt, "K:\", "D:\Data\")
Also response.write
is for ASP ...
来源:https://stackoverflow.com/questions/22043691/code-error-800a01a8-object-required