Set WshShell = WScript.CreateObject ("WScript.Shell")
wscript.echo "Argument Count", wscript.arguments.count
For I = 0 to wscript.arguments.count - 1
Wscript.Echo wscript.arguments.item(I)
Next
set cdrom = wscript.arguments.item(0)
set basedir = wscript.arguments.item(1)
wscript.echo cdrom, basedir
When I run it from the command line I get the following output:
G:\Deployment\CDROM\INSTALL>cscript.exe test.vbs g: g:\deployment\cdrom\install
Microsoft ® Windows Script Host Version 5.6
Copyright © Microsoft Corporation 1996-2001. All rights reserved.
Argument Count 2
g:
g:\deployment\cdrom\install
G:\Deployment\CDROM\INSTALL\
test.vbs(9, 1) Microsoft VBScript runtime error: Object required: '[string: "g:"]'
Why? I thought that the item is a string value, but it doesn't seem to like it. What I'm trying to do is to make a VBScript to install software that requires user input, but also takes arguments as to where the install executable is located. Here's what I have so far for lookout120.exe, which gives the same type of error:
Set WshShell = WScript.CreateObject ("WScript.Shell")
Set Ag = Wscript.Arguments
' Process command line arguments
if Ag.count < 2 Then
WScript.Echo "Command Line Error. Need <CDROM> <Base Dir>" & vbcrlf
WScript.Quit
End if
set cdrom = Ag.item(0)
set basedir = Ag.item(1)
' execute program
WshShell.Run (basedir & "\COMPONENT\LOOKOUT\LookOut120.exe /S")
' wait for startup and then start sending keystrokes
WScript.Sleep 5000
WshShell.SendKeys "{SPACE}"
' Wait for install to finish
WScript.Sleep 10000
' Quit
WScript.Quit
What am I doing wrong?



Help

Back to top









