我需要使用QTP验证PDF中的特定内容.如何将PDF中的内容导入到使用QTP/VBScript的字符串中.这样,我就可以验证PDF中的内容.
当我尝试运行该脚本时,它会抛出该文件不存在的错误.在脚本上它确实存在echos文件.尝试过objshell.run"""apppath"""但没有运气.. :(请帮助.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
AppPath = objshell.ExpandEnvironmentStrings("%ProgramFiles%") + "\ERUNT\ERUNT.EXE"
wscript.echo apppath
if fx = objfso.FileExists("apppath") then
wscript.Echo "File Exists"
objshell.run apppath
Else
Wscript.echo "File Does not Exist"
end IF
Run Code Online (Sandbox Code Playgroud) 例如,如果我在VBscript中有一个函数:
Function sum(a, b, c)
sum = a + b + c
End function
Run Code Online (Sandbox Code Playgroud)
现在,在main中,我创建两个变量并将它们传递给函数sum,如下所示:
Dim a : a = 1
Dim b : b = 2
Call sum(a, b)
Run Code Online (Sandbox Code Playgroud)
这会起作用吗?为什么?谢谢.
当单击iframe中的按钮时,此HTML文件会显示消息对话框:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="VBScript" type="text/vbscript">
Sub load_me()
frame.document.write "<input type='button' onclick='parent.message()'>"
End Sub
Sub message()
MsgBox "Hi"
End Sub
</script>
</head>
<body>
<iframe id="frame" onload="load_me"></iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
与HTA文件相同的文档,引发错误Error: Object doesn't support this property or method::
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<HTA:APPLICATION
APPLICATIONNAME="Test"
ID="MyHTMLapplication"
VERSION="1.0"/>
<script language="VBScript">
Sub load_me()
frame.document.write "<input type='button' onclick='parent.message()'>"
End Sub
Sub message()
MsgBox "Hi"
End Sub
</script>
</head>
<body bgcolor="white">
<iframe …Run Code Online (Sandbox Code Playgroud) 我在这里阅读了一篇非常有用的文章如何在JavaScript中创建字符串大写的第一个字母?我很好奇使用VBScript的一个很好的解决方案.
我正在使用此代码:
Dim name
name = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%computername%")
Set wmi = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& name & "\root\cimv2")
For Each hwnd In wmi.InstancesOf("Win32_Process")
If hwnd.Name = "wscript.exe" Then
'get name and possibly location of currently running script
End If
Next
Run Code Online (Sandbox Code Playgroud)
我成功列出了所有流程并选择了wscript.exe.但是,我搜索过,发现没有办法找到运行的脚本的名称wscript.exe,即.是myscript.vbs或jscript.js什么的.如果有办法找到脚本的整个路径,可以获得奖励.
编辑:
通过更多搜索,我找到了解决方案.在上面的脚本中,hwnd变量存储wscript.exe进程的句柄.手柄有一个属性:hwnd.CommandLine.它显示了如何从命令行调用它,所以它将是这样的:
"C:\Windows\System32\wscript.exe" "C:\path\to\script.vbs"
Run Code Online (Sandbox Code Playgroud)
所以我可以解析hwnd.CommandLine字符串来查找所有正在运行的脚本的路径和名称.
我想使用VBScript将地址注入"远程桌面连接"提示符.我被特别告知我必须使用Windows Automation API来做到这一点,但在阅读文档之后,我没有找到任何可以用于VBScript的东西.我该怎么办?
PS:正如Helen和此主题所指出的,目前不支持VBScript访问UI Automation API.
我使用下面的脚本来调用另一个脚本.问题是我必须将我通过WScript.Arguments检索的参数传递给我正在调用的第二个脚本.有人请告诉我该怎么做.
Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "TestScript.vbs"
Set objShell = Nothing
Run Code Online (Sandbox Code Playgroud) 我正在研究VBA,我必须通过传递一些值来调用vbscript.
这是代码:
''VBA
'Below values are on different cells of Excel file which I am reading
'into a global variable then pass it to vbscript.
'SFilename = VBscript file path
'QClogin = "abc"
'QCpassword = "abc"
'sDomain = "xyz"
'sProject = "xyz123"
'testPathALM = "Subject\xyz - Use it!\xyz_abc"
'QCurl = "http://xxx_yyy_zzz/qcbin/"
Set wshShell = CreateObject("Wscript.Shell")
Set proc = wshShell.exec("wscript " & SFilename & " " & QClogin & _
" " & "" & QCpassword & " " & "" …Run Code Online (Sandbox Code Playgroud) 我是一个完整的VBScript新手,我正在尝试执行存储过程并读取结果集.我尝试了许多不同的方法在线使用文章,但没有任何作用,我很难过.数据库是SQL Server 2008 R2,该应用程序是一个现成的ERP系统,但我可以添加自己的代码.
我可以使用以下命令执行代码:
connection.execute"insert into blah blah blah"
Run Code Online (Sandbox Code Playgroud)
我可以使用以下方法读取结果集:
Set objRS = CreateObject("ADODB.Recordset")
objRS.Open "select a, b, c FROM blahblah", Connection, adOpenStatic, adLockBatchOptimistic, adCmdText
If objRS.EOF = False Then
a = objRS.Fields("a").Value
b = objRS.Fields("b").Value
c = objRS.Fields("c").Value
End If
objRS.Close
Run Code Online (Sandbox Code Playgroud)
有问题的存储过程实际上是一个select语句,例如:
create procedure [dbname].[dbo].[sptestproc]
as
@Option1 Varchar(10) = NULL,
@Option2 Varchar(10) = NULL
AS
BEGIN
select first, second
from table1
where a = @option1 and b = @toption2
End
Run Code Online (Sandbox Code Playgroud)
我的代码到目前为止:
Dim sql
sql = "EXEC [dbname].[dbo].[sptestproc] '" …Run Code Online (Sandbox Code Playgroud) vbscript ×10
automation ×1
excel ×1
excel-vba ×1
hta ×1
html ×1
overloading ×1
qtp ×1
syntax ×1
validation ×1
vba ×1
windows ×1