"需要与QUOT对象;当使用坐落在一个任务 [英] "Object required" when using Set in an assignment
问题描述
调用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命令行中的
方法。这是我在打破code,清理它,然后把它重新走到一起首次尝试。WScript.Shell
对象的实例化()
块引用>原来的答案
您
设置SCMD
应实例化WScript.Shell
(作为的 Ekkehard.Horner 指出,你可以使用的Server.CreateObject(WScript.Shell)运行$ C。 $ C>为一次性的参考,但我不会推荐它)。
的
.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运行可执行文件有一些事情要考虑;
运行命令将执行使用当前的应用程序池标识。
执行命令不会在客户端(服务器端)在服务器上执行的可执行文件。
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 lineSet 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
Your
Set scmd
should be instantiating theWScript.Shell
(As Ekkehard.Horner points out you can useServer.CreateObject("WScript.Shell").Run
for a one off reference but I wouldn't recommend it).The
.Run()
should be executed by the instantiatedscmd
object and passed the command line to execute.Here is an example I've renamed some of the variables (
scmd
tocmd
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;
Run command will execute using the current Application Pool identity.
Run will execute the executable on the server not at the client (server side).
这篇关于"需要与QUOT对象;当使用坐落在一个任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!