Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


invalid procedure call or argument error

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3547
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> invalid procedure call or argument error
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 invalid procedure call or argument error - 6/27/2005 12:42:08 PM   
  marcusrp

 

Posts: 145
Score: 0
Joined: 4/19/2005
From:
Status: offline
Does anyone know why I would get an 'invalid procedure call or argument on row 5, char 1' with the following script? (its actually refering to the line >>>Set objFileName = objnoResponse.OpenTextFile("c:\compnames.txt", ForReading, 0)<<<, in case formatting on this forum messes up the code layout...

I've used this exact line in other scripts, I don't know why it won't work here...

Set objnoResponse = CreateObject("Scripting.FileSystemObject")

Set Response = objnoResponse.CreateTextFile("c:\response.txt", ForAppending, True)
Set noResponse = objnoResponse.CreateTextFile("c:\noresponse.txt", ForAppending, True)
Set objFileName = objnoResponse.OpenTextFile("c:\compnames.txt", ForReading, 0)
Do While objFileName.AtEndOfStream <> True
strLine = objFileName.Readline
Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec( _
"ping -n 2 -w 1000 " & strLine)
strPingResults = LCase(objScriptExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
Response.WriteLine("Response!" & strLine)
else
noResponse.WriteLine("NO Response!" & strLine)
end if
Loop

thanks!
 
 
Post #: 1
 
 Re: invalid procedure call or argument error - 6/27/2005 3:58:00 PM   
  Xandros

 

Posts: 100
Score: 0
Joined: 6/23/2005
From:
Status: offline
This script doesn't define "ForReading" and "ForAppending"... add the following line to the top of the script:

Const ForReading = 1, ForAppending = 8

Good coding practice calls for always having "Option Explicit" as the first line... it will greatly reduce this type of error.

(in reply to marcusrp)
 
 
Post #: 2
 
 Re: invalid procedure call or argument error - 6/27/2005 5:42:00 PM   
  ehvbs

 

Posts: 2220
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
If this

      
works, but this

      
fails, than I would suspect the "0" instead of the expected boolean value.

(in reply to marcusrp)
 
 
Post #: 3
 
 Re: invalid procedure call or argument error - 6/28/2005 3:40:39 AM   
  marcusrp

 

Posts: 145
Score: 0
Joined: 4/19/2005
From:
Status: offline
its a pieced together quickie code for a limited run process, so i have to admit I'm being a bit sloppy with the code, thanks for the responses I'll let know what works

(in reply to marcusrp)
 
 
Post #: 4
 
 Re: invalid procedure call or argument error - 6/28/2005 4:12:15 AM   
  marcusrp

 

Posts: 145
Score: 0
Joined: 4/19/2005
From:
Status: offline
defining the constants worked, thanks

(in reply to marcusrp)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> invalid procedure call or argument error Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts