"需要与QUOT对象;当使用坐落在一个任务 [英] "Object required" when using Set in an assignment

查看:123
本文介绍了"需要与QUOT对象;当使用坐落在一个任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 调用main()
子的main()
    昏暗SCMD
    设置SCMD =C:\\ WINDOWS \\ SYSTEM32 \\ //将Cscript.exe NOLOGO C:\\ s.vbs
    CREATEOBJECT(wscript.shell)。运行SCMD,0,假
分结束

它给了我错误:


  

所需的对象:'[字符串:C:\\ WINDOWS \\ SYSTEM32 \\]code 800A01A8



解决方案

  

更新


  
  

由于目前还不清楚觉得最好的指出你的对象需要的问题是,由于这一行


  
  

设置SCMD =C:\\ WINDOWS \\ SYSTEM32 \\ //将Cscript.exe NOLOGO C:\\ s.vbs

这是因为一个对象预期,但你分配一个字符串,通过删除设置您code将工作(作为的 Ekkehard.Horner 指出 )。


  
  

  
  

下面是我的情况除pretation。首先看你的code几乎看起来像它混有对 .RUN命令行中的 WScript.Shell 对象的实例化()方法。这是我在打破code,清理它,然后把它重新走到一起首次尝试。



原来的答案


  1. 设置SCMD 应实例化 WScript.Shell (作为的 Ekkehard.Horner 指出,你可以使用的Server.CreateObject(WScript.Shell)运行为一次性的参考,但我不会推荐它)。


  2. .RUN()应由实例化 SCMD 对象执行,并通过命令行来执行。


下面是我改名一些变量的一个实例( SCMD CMD 为例)。

调用的main()子的main()
    改名变量cmd是你的对象,CMDLINE是你的文件路径。
    暗淡CMD,CMDLINE
    实例化WshShell对象
    设置CMD =的Server.CreateObject(WScript.Shell)
    '设置CMDLINE变量文件路径
    CMDLINE =C:\\ WINDOWS \\ SYSTEM32 \\ //将Cscript.exe NOLOGO C:\\ s.vbs
    执行运行,并立即返回
    呼叫cmd.Run(CMDLINE,0,FALSE)
结束小组


需要考虑的事情

在经典ASP中使用WScript.Shell运行可执行文件有一些事情要考虑;


  1. 运行命令将执行使用当前的应用程序池标识。


  2. 执行命令不会在客户端(服务器端)在服务器上执行的可执行文件。


call main()
sub main()
    Dim scmd
    Set scmd = "c:\windows\system32\cscript.exe //nologo c:\s.vbs"
    createobject("wscript.shell").run scmd,0,false
end sub

It gives me error:

Object required: '[string: "c:\windows\system32\"]' Code 800A01A8

解决方案

Update

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

Set scmd = "c:\windows\system32\cscript.exe //nologo c:\s.vbs"

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


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.


Original Answer

  1. Your Set scmd should be instantiating the WScript.Shell (As Ekkehard.Horner points out you can use Server.CreateObject("WScript.Shell").Run for a one off reference but I wouldn't recommend it).

  2. The .Run() should be executed by the instantiated scmd object and passed the command line to execute.

Here is an example I've renamed some of the variables (scmd to cmd for example).

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:\windows\system32\cscript.exe //nologo c:\s.vbs"
    'Execute Run and return immediately
    Call cmd.Run(cmdline, 0, False)
End Sub


Things to consider

When using WScript.Shell in Classic ASP to run executables there are some things to consider;

  1. Run command will execute using the current Application Pool identity.

  2. Run will execute the executable on the server not at the client (server side).

这篇关于"需要与QUOT对象;当使用坐落在一个任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆