由于某种原因,我无法使用JavaScript在.hta中调用curl.exe。以.hta
格式运行以下示例(仅作为示例)<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
w=new ActiveXObject("WScript.Shell")
w.run('"C:\\Windows\\System32\\curl.exe" "https://www.google.com" -o t.txt')
</script>
</body>
</html>
导致文件未找到错误,尽管System32目录中肯定存在curl.exe。但是,如果我调用位于不同目录中的curl.exe,则工作正常,如果将目录添加到PATH中,也可以使用“ curl”。也正在运行可以在System32目录中使用notepad.exe或fc.exe。
我也尝试使用VBScript在.hta中启动curl,但这也不起作用。但是如果我用
创建.jsw=new ActiveXObject("WScript.Shell")
w.run('"C:\\Windows\\System32\\curl.exe" "https://www.google.com" -o t.txt')
或.vbs与
Set w = CreateObject("Wscript.Shell")
w.Run("""C:\\Windows\\System32\\curl.exe"" ""https://www.google.com"" -o t.txt""")
都很好。
那么在.hta中调用curl的原因是什么?是出于某些(安全性)原因将其列入黑名单,还是某个地方存在错误,还是我做错了什么?
编辑:尝试调用.bat调用curl。同一故事:如果.bat调用C:\ Windows \ System32 \ curl,则在.hta中调用时将不起作用,但在.js或.vbs中调用时将起作用。调用SomeOtherDirectory \ curl.exe即可。
答案 0 :(得分:2)
我终于设法将写词输入到Google和found what was wrong。 HTA文件由32位mshta.exe运行,这会导致C:\ Windows \ System32重定向到不包含curl.exe的C:\ Windows \ SysWOW64。用Sysnative替换System32使.hta起作用。
w.run('"C:\\Windows\\Sysnative\\curl.exe" "https://www.google.com" -o t.txt')