怎么在vb里运行vbs代码
怎么把这段代码在vb中运行DimWshShellSetWshShell=WScript.CreateObject("WScript.Shell")'让脚本等待1000毫秒...
怎么把这段代码在vb中运行 Dim WshShell Set WshShell=WScript.CreateObject("WScript.Shell") ' 让脚本等待1000毫秒,也就是1秒再执行下一条语句 WScript.Sleep 5000 WshShell.SendKeys "j{enter}" WScript.Sleep 1000 WshShell.SendKeys "m{enter}"
展开
1个回答
展开全部
将代码保存为脚本文件,如保存到C\1.vbs
然后在vb中引用api函数:
Private
Declare
Function
ShellExecute
Lib
"shell32.dll"
Alias
"ShellExecuteA"
(ByVal
hwnd
As
Long,
ByVal
lpOperation
As
String,
ByVal
lpFile
As
String,
ByVal
lpParameters
As
String,
ByVal
lpDirectory
As
String,
ByVal
nShowCmd
As
Long)
As
Long
这样调用这个函数就好了
Private
Sub
Command1_Click()
Dim
VBS
As
String
VBS
=
"C:\1.vbs"
‘文件路径
ShellExecute
ByVal
0,
"open",
VBS,
ByVal
0,
ByVal
0,
ByVal
0
End
Sub
然后在vb中引用api函数:
Private
Declare
Function
ShellExecute
Lib
"shell32.dll"
Alias
"ShellExecuteA"
(ByVal
hwnd
As
Long,
ByVal
lpOperation
As
String,
ByVal
lpFile
As
String,
ByVal
lpParameters
As
String,
ByVal
lpDirectory
As
String,
ByVal
nShowCmd
As
Long)
As
Long
这样调用这个函数就好了
Private
Sub
Command1_Click()
Dim
VBS
As
String
VBS
=
"C:\1.vbs"
‘文件路径
ShellExecute
ByVal
0,
"open",
VBS,
ByVal
0,
ByVal
0,
ByVal
0
End
Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询