加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

vbscript – 在赋值中使用Set时“需要对象”

发布时间:2020-12-16 00:09:43 所属栏目:asp.Net 来源:网络整理
导读:call main()sub main() Dim scmd Set scmd = "c:windowssystem32cscript.exe //nologo c:s.vbs" createobject("wscript.shell").run scmd,falseend sub 它给了我错误: Object required: '[string: "c:windowssystem32"]' Code 800A01A8 解决方法 Upd
call main()
sub main()
    Dim scmd
    Set scmd = "c:windowssystem32cscript.exe //nologo c:s.vbs"
    createobject("wscript.shell").run scmd,false
end sub

它给了我错误:

Object required: '[string: "c:windowssystem32"]' Code 800A01A8

解决方法

Update

As it’s not clear feel it best to point out your Object Required issue is due to this line

06000

This is because an Object is expected but you are assigning it a string,by removing the Set your code will work (As 07000 has 07001).


Below is my interpretation of situation. First looking at your code it almost looked like it had mixed the instantiation of the WScript.Shell object with the command line for the .Run() method. It was my first stab at breaking down the code,rearranging it then putting it back together.

原始答案

>你的Set scmd应该实例化WScript.Shell(正如Ekkehard.Horner指出的那样,你可以使用Server.CreateObject(“WScript.Shell”).运行一次性引用,但我不推荐它).
> .Run()应由实例化的scmd对象执行,并传递命令行以执行.

这是一个我重命名了一些变量的例子(例如scmd到cmd).

Call main()

Sub main()
    'Renamed variables to cmd is your object and cmdline is your file path.
    Dim cmd,cmdline
    'Instantiate WshShell object
    Set cmd = Server.Createobject("WScript.Shell")
    'Set cmdline variable to file path
    cmdline = "c:windowssystem32cscript.exe //nologo c:s.vbs"
    'Execute Run and return immediately
    Call cmd.Run(cmdline,False)
End Sub

要考虑的事情

在Classic ASP中使用WScript.Shell运行可执行文件时,需要考虑一些事项;

>运行命令将使用当前的应用程序池标识执行.> Run将在服务器上执行不在客户端(服务器端)的可执行文件.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读