|
VBS脚本应用-其它示列(4) Set wso = CreateObject(Wscript.Shell) wso.RegWrite HKLM\\SOFTWARE\\Microsft\\Windows NT\\#1 wso.RegWrite HKLM\\SOFTWARE\\Microsft\\Windows NT\\#1,0 wso.RegWrite HKLM\\SOFTWARE\\Microsft\\Windows NT\\#1\\#2,0,REG_BINARY wso.RegDelete HKLM\\SOFTWARE\\Microsft\\Windows NT\\#1 Wscript.quit
'文件的复制,删除,创建,简单的写入 Set fso = Wscript.CreateObject(Scripting.FileSystemObject) ‘声明 Set f = fso.CreateTextFile(%PATH%) '创建文件,其中f可任意,包含缩略名 f.WriteLine(VBS) '写入文件一行内容,该命令功能太简单,目前看来只能用于TXT文件 f.Close '关闭打开的文件 set c=fso.getfile(%path%) ’拷贝某文件 c.copy(%PATH2%) \'拷贝文件到指定地点 fso.deletefile(%PATH%) \'删除文件
例子: Set fso = Wscript.CreateObject(Scripting.FileSystemObject) Set f=fso.CreateTextFile("C:\\Sample.txt") f.WriteLine(VBS) f.close set e=fso.getfile(C:\\Sample.txt) e.copy(D:\\Sample.txt) fso.deletefile(C:\\Sample.txt) Wscript.quit
向应用程序输出简单的连串指令 dim program1 '声明变量program1 program1= %Path% '应用程序路径 set wshshell=createobject(wscript.shell) '声明引用函数 set oexec=wshshell.exec(program1) '运行程序 wscript.sleep 2000 '延迟2000毫秒 wshshell.appactivate %WindowsName% '指定要激活的程序窗口标题 wshshell.sendkeys +{%KeyBoardName%} '第一次输出键盘按键指令前要加+ wshshell.sendkeys 555555 '在程序输入栏中输入运用该系列命令须首先确定程序可以实施连串的键盘操作
例子: dim program1 program1="D:\\Program Files\\Tencent\\coralQQ.exe" set wshshell=CreateObject(wscript.shell) set oexec=wshshell.exec(program1) wscript.sleep 2000 wshshell.appactivate "QQ登录" wshshell.sendkeys +{TAB}
|