SystemUtil.Run in UFT gives me “invalid procedure

2019-09-08 14:53发布

I'm using SystemUtil.Run (pathName) in UFT, VBScript. But it gives me

invalid procedure call or argument.

I'm sure about pathName, I'm sure about the command, I'm sure about everything. What do you think might be the cause?

2条回答
我命由我不由天
2楼-- · 2019-09-08 15:48

I have ran into the same issue. I had to write the full path name for the error to go away.

example: SystemUtil.Run "C:\Program Files\Internet Explorer\iexplore.exe", "www.google.com"

I hope this helps you.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-09-08 15:57

If you look at the examples here, you'll see that the approved call is

SystemUtil.Run pathName

(passing pathName per reference) instead of

SystemUtil.Run (pathName)

(passing a const copy).

Eric Lippert's essay should help you to understand the use of () in VBScript.

Evidence:

As I don't use UFT, I can only use .NET to demonstrate that the ()/parameter passing mode matters:

>> Set m_oSB = CreateObject("System.Text.StringBuilder")
>> aData = Split("a b c")
>> m_oSB.AppendFormat_4 "{0}-{1}-{2}", (aData)
>> WScript.Echo m_oSB.ToString()
>>
a-b-c
>> m_oSB.AppendFormat_4 "{0}-{1}-{2}", aData
>>
Error Number:       5
Error Description:  Invalid procedure call or argument
>>
查看更多
登录 后发表回答