vbs代码问题 如何用vbs打开一个指定程序,然后在程序上输入密码

vbs代码问题 如何用vbs打开一个指定程序,然后在程序上输入密码,第1张

Option Explicit

Dim objShell, strProgram, strKeys

Set objShell = CreateObject("WscriptShell")

strKeys = "Hello world" '要发送的字符,请自己更改

strProgram = "c:\windows\system32\notepadexe" '需要打开的程序,请自己指定

With objShell

Run strProgram

WScriptSleep 500

SendKeys strKeys

SendKeys "~"

End With

Set objShell = Nothing

set

wshshell

=

createobject("wscriptshell")

wshshellrun

"notepadexe",

,

true

'这条语句等到被打开序关闭时才执行下一句。

也可以循环监视

oexecstatus

=wshfinished

确定程序是否已退出

打开IE直接用。

Dim objws

Set objws=WScriptCreateObject("wscriptshell")

objwsRun "iexplore"

要打开其它程序把iexplore换为其它程序的路径。

给你个思路吧:

你打开的是1txt,那么这个TXT的标题就是"1txt - 记事本",你可以在Timer控件下写代码,判断是否存在窗口"1txt - 记事本",存在则运行其他程序,不存在则继续监视!

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long

Private Sub Timer1_Timer()

winHwnd = FindWindow(vbNullString, "1txt - 记事本")

If winHwnd <> 0 Then

shell "" ,vbhide

End If

End Sub

回答的太急都没看清是VBS,回答错了,我回答的是VB的,不好意思哈

代码如下:

Dim WS

'Dim variable

Set WS=WScriptCreateObject("WScriptShell")

'Create object

WSRun "",1

'上面一行双引号中键入文件路径逗号后面的"1"意思为正常运行此程序,改为0可隐藏运行

WSRun "taskkill /f /im notepadexe",0

'以上是一个关闭记事本的代码示例将"notepadexe"改成你想要结束的进程可关闭相应的程序

set ws=createobject("wscriptshell")

pro="c:\windows\system32\notepadexe"

n=split(pro,"\")

name=n(ubound(n))

for each ps in getobject("winmgmts:\\\root\cimv2:win32_process")instances_

s=s&sep&psname:sep="|":next

wscriptsleep 500

wsappactivate "记事本"

s=split(s,"|")

for i=0 to ubound(s)

if name=s(i) then wscriptquit

next

wsrun pro

望采纳。

path =Replace(WScriptScriptFullName,WScriptScriptName,"")

Set s = WScriptCreateObject("WscriptShell")

sRun path & "TTPlayerexe" '打开千千静听程序

以上就是关于vbs代码问题 如何用vbs打开一个指定程序,然后在程序上输入密码全部的内容,包括:vbs代码问题 如何用vbs打开一个指定程序,然后在程序上输入密码、怎样在VBS运行后自动打开另一个程序、如何在VBS脚本中打开一个外部程序如(IE)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/10208861.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-06
下一篇2023-05-06

发表评论

登录后才能评论

评论列表(0条)

    保存