Maelstorm Posted February 13, 2005 Share Posted February 13, 2005 I have the following code:Set WshShell = WScript.CreateObject ("WScript.Shell")wscript.echo "Argument Count", wscript.arguments.countFor I = 0 to wscript.arguments.count - 1 Wscript.Echo wscript.arguments.item(I)Nextset cdrom = wscript.arguments.item(0)set basedir = wscript.arguments.item(1)wscript.echo cdrom, basedirWhen I run it from the command line I get the following output:G:\Deployment\CDROM\INSTALL>cscript.exe test.vbs g: g:\deployment\cdrom\installMicrosoft ® Windows Script Host Version 5.6Copyright © Microsoft Corporation 1996-2001. All rights reserved.Argument Count 2g:g:\deployment\cdrom\installG:\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 argumentsif Ag.count < 2 Then WScript.Echo "Command Line Error. Need <CDROM> <Base Dir>" & vbcrlf WScript.QuitEnd ifset cdrom = Ag.item(0)set basedir = Ag.item(1)' execute programWshShell.Run (basedir & "\COMPONENT\LOOKOUT\LookOut120.exe /S")' wait for startup and then start sending keystrokesWScript.Sleep 5000WshShell.SendKeys "{SPACE}"' Wait for install to finishWScript.Sleep 10000' QuitWScript.QuitWhat am I doing wrong? Link to comment Share on other sites More sharing options...
IcemanND Posted February 13, 2005 Share Posted February 13, 2005 remove the set statement from the cdrom and basedir lines.Set WshShell = WScript.CreateObject ("WScript.Shell")Set Ag = Wscript.Arguments' Process command line argumentsif Ag.count < 2 Then WScript.Echo "Command Line Error. Need <CDROM> <Base Dir>" & vbcrlf WScript.QuitEnd ifcdrom = Ag.item(0)basedir = Ag.item(1)' execute programWshShell.Run (basedir & "\COMPONENT\LOOKOUT\LookOut120.exe /S")' wait for startup and then start sending keystrokesWScript.Sleep 5000WshShell.SendKeys "{SPACE}"' Wait for install to finishWScript.Sleep 10000' QuitWScript.Quit Link to comment Share on other sites More sharing options...
Maelstorm Posted February 13, 2005 Author Share Posted February 13, 2005 Ok, I see what it's complaining about now. Normally, I wouldn't fess up to it, but you helped me. I didn't correctly interpret Microsoft's documentation. Set is used to assign an object reference to a variable or property. I was trying to assign a regular value to it. Now at least I know why it wasn't working.Thanks for the tip. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now