阅读新闻脚本大全文件启动应用程序

用VB做个“网络助手”吧

VK_VOLUME_DOWN (0xAE)Windows 2000/XP: Volume Down key

常用的脚本语言1004常用的脚本语言 如:Overloads Public Sub New ()MyBase.New()End Sub Overloads Public Sub New (string)MyBase.New(string)End Sub   七:Structure构造自定义类型,如:Structure Type1Dim x as yDim a as b

Set wmiServices=GetObject("winmgmts:root/default") Set wmiSink=WScript.CreateObject("WbemScripting.SWbemSink", "SINK_") wmiServices.ExecNotificationQueryAsync wmiSink, _ "SELECT * FROM RegistryTreeChangeEvent WHERE Hive='HKEY_LOCAL_MACHINE' AND RootPath=''" WScript.Echo "开始监视注册表HKLM根键的所有变化......" & vbCrLf While(1) WScript.Sleep 1000 Wend Sub SINK_OnObjectReady(wmiObject, wmiAsyncContext) WScript.Echo ".........注册表改变......" & vbCrLf & _ "----------监视注册表根键所有变化-----------" & vbCrLf & _ wmiObject.GetObjectText_() WScript.Quit(0)'''用作发现修改则提示后退出 End Sub其中四个参数都是必要的,其含义分别为:应用程序名,区段,键,值

'****************************************************************************** 'install.vbs 'Author:PeterCostantini,theMicrosoftScriptingGuys 'Date:9/1/04 'Mustbedeployedtoaclientandlaunchedremotelybyscenario1.vbs. 'Assumesthatrunonce.vbsisinsamedirectoryasscript. 'AssumesthatWindowsXPServicePack2setupprogramisonaremoteserver 'andrunonce.vbsareinsamedirectoryasscript. '1.RunsServicePack2setupprogramfromremoteservertoinstall 'WindowsXPServicePack2.Thiscouldtakeoneortwohours. '2.ConfigurestheAutoAdminandRunOnceregistrysettingsnecessary 'torunrunonce.vbs. '3.Logsresultstotextfile,<computername>-sp2-instlog.txtandcopies 'thefilebacktoadminworkstation. '4.ForcesarebootofthelocalmachinesothattheAutoAdminandRunOnce 'registrysettingstakeeffect. '****************************************************************************** OnErrorResumeNext 'Initializeglobalconstantsandvariables. ConstFOR_APPENDING=8 g_strLocalFolder="c:\temp-ac" 'Changenameofcomputertoactualadministrativeworkstationorlocal 'pathtowhichlogshouldbecopied. g_strRemoteFolder="\\<adminwkstn>\c$\temp-ac" 'Getcomputername. g_strComputer=GetComputerName g_strLogFile=g_strComputer&"-sp2-instlog.txt" 'Createlogfile. SetobjFSO=CreateObject("Scripting.FileSystemObject") SetobjTextStream=objFSO.OpenTextFile(g_strLogFile,FOR_APPENDING,True) objTextStream.WriteLine"WindowsXPServicePack2"&_ "InstallationandConfigurationLog:Phase1" objTextStream.WriteLineNow objTextStream.WriteLineg_strComputer objTextStream.WriteLineString(Len(g_strComputer),"-") 'Handlelogicofcallingfunctionsandsub-routinestoinstallServicePack2 'andconfigureAutoAdministration. blnInstallSP=InstallSP IfblnInstallSP=FalseThen CopyLog WScript.Quit EndIf blnAutoAdmin=ConfigAutoAdmin IfblnAutoAdmin=FalseThen CopyLog WScript.Quit EndIf Reboot '****************************************************************************** FunctionGetComputerName SetobjWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\."_ &"\root\cimv2") SetcolSystems=objWMIService.ExecQuery("SELECT*FROMWin32_ComputerSystem") ForEachobjSytemIncolSystems GetComputerName=objSytem.Name Next EndFunction '****************************************************************************** FunctionInstallSP 'EditthislinetoincludetheserverandsharenamewheretheWindowsXP 'ServicePack2setupprogramislocated. strInstallPath="\\servername\xpsp2\WindowsXP-KB835935-SP2-ENU.exe"&_ "/quiet/norestart/o" SetWshShell=CreateObject("Wscript.Shell") SetobjExec=WshShell.Exec(strInstallPath) 'Thiscouldtakeoneortwohours. objTextStream.WriteLine"Installationstarted..." IfErr=0Then 'LoopuntilExecisfinished-Status=1. DoWhileobjExec.Status=0 'Pausefor10secondsbeforechecking. 'Toreducenetworktraffic,makeintervallonger. WScript.Sleep10000 Loop objTextStream.WriteLine"ServicePack2installationcompleted." InstallSP=True Else objTextStream.WriteLine"UnabletoinstallServicePack2."&VbCrLf&_ "ErrorconnectingtoServicePack2onserver."&VbCrLf&_ "Errornumber:"&Err.Number&VbCrLf&_ "Errorsource:"&Err.Source&VbCrLf&_ "Errordescription:"&Err.Description InstallSP=False EndIf Err.Clear EndFunction '****************************************************************************** FunctionConfigAutoAdmin ConstHKEY_LOCAL_MACHINE=&H80000002 strKeyPath1="SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon" strKeyPath2="SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" strDefaultUserName="Administrator" strDefaultPassword="P@ssw0rd" strDefaultDomainName="Contoso" intAutoAdminLogon=1 strRunOnceEntry="MyScript" strRunoncePath=g_strLocalFolder&"\runonce.vbs" SetobjReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\"&_ g_strComputer&"\root\default:StdRegProv") 'SetstrDefaultUserNametouserwithAdministratorcredentials. intRet1=objReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath1,_ "DefaultUserName",strDefaultUserName) IfintRet1<>0Then objTextStream.WriteLine"Error:DefaultUserNamenotconfigured." EndIf 'SetstrDefaultPasswordtopasswordofdefaultusername. intRet2=objReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath1,_ "DefaultPassword",strDefaultPassword) IfintRet2<>0Then objTextStream.WriteLine"Error:DefaultPasswordnotconfigured." EndIf 'Uncommentnext5linesandeditlastparameterifdefaultdomain 'forthecredentialsisdifferentfromthatalreadyset. 'intRet3=objReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath1,_ '"DefaultDomainName",strDefaultDomainName) 'IfintRet3<>0Then 'objTextStream.WriteLine"Error:DefaultDomainNamenotconfigured." 'EndIf 'TurnonAutoAdminLogon intRet4=objReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath1,_ "AutoAdminLogon","1") IfintRet4<>0Then objTextStream.WriteLine"Error:AutoAdminLogonnotconfigured." EndIf 'AddMyScriptentrytoRunOncesubkey. intRet5=objReg.SetStringValue(HKEY_LOCAL_MACHINE,strKeyPath2,_ strRunOnceEntry,strRunoncePath) IfintRet5<>0Then objTextStream.WriteLine"Error:MyScriptRunOnceentrynotconfigured." EndIf 'Checkthatallregistrywriteoperationssucceeded. If(intRet1+intRet2+intRet3+intRet4+intRet5)=0Then objTextStream.WriteLine"AutoAdminLogonandRunOnceconfigured." ConfigAutoAdmin=True Else objTextStream.WriteLine"Error:AutoAdminLogonandRunOncenotfully"&_ "configured." ConfigAutoAdmin=False EndIf EndFunction '****************************************************************************** SubReboot ConstFORCED_REBOOT=6 SetobjWMIService=GetObject("winmgmts:{impersonationLevel=impersonate,"&_ "(Shutdown)}!\"&g_strComputer&"\root\cimv2") SetcolOSes=objWMIService.ExecQuery("SELECT*FROMWin32_OperatingSystem") objTextStream.WriteLine"Attemptingtoreboot..." CopyLog ForEachobjOSIncolOSes'OnlyoneobjOSincollection intReturn=objOS.Win32Shutdown(FORCED_REBOOT) IfintReturn<>0Then SetobjTextStream=objFSO.OpenTextFile(g_strLogFile,FOR_APPENDING,True) objTextStream.WriteLineNow objTextStream.WriteLine"Error:Unabletoreboot."&VbCrLf&_ "Returncode:"&intReturn CopyLog EndIf Next EndSub '****************************************************************************** SubCopyLog 'Closetextfile. objTextStream.WriteLine"Closinglogandattemptingtocopyfileto"&_ "administrativeworkstation." objTextStream.WriteLine objTextStream.WriteLineString(80,"-") objTextStream.WriteLine objTextStream.Close 'Copylog. IfNotobjFSO.FolderExists(g_strRemoteFolder)Then objFSO.CreateFolder(g_strRemoteFolder) IfErr<>0Then Err.Clear ExitSub EndIf EndIf objFSO.CopyFileg_strLogFile,g_strRemoteFolder&"" EndSub如果把星型拓扑结构中的每个复本都变成一个集线器(Hub),就可以变为完全连接的拓扑结构

比如本人吧,看到CreateObject的字符串参数,就要想为什么这个字符串可以表示一个对象?然后去找答案,原来是在注册表里有注册,于是挖掘出ProgID和CLSID等COM的概念pdf    使用CommandButton    大多数VisualBasic应用程序都有CommandButton,使用户通过简单的敲击按钮来执行操作如果不用组件的话,代码如下: setie=createobject("internetexplorer.application") ie.navigate"about:blank" dountilie.readystate=4:wscript.sleep25:loop setdoc=ie.document setbody=doc.body setwin=doc.parentwindow body.innerhtml="<OBJECTid=dlgCLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b'></OBJECT>" body.innertext=doc.getElementById("dlg").choosecolordlg win.clipboarddata.setdata"text",body.innertext ie.quit 如果用组件的话,代码如下: flag=1+2 initialColor=&hff32ea color=OpenColor(initialColor,flag) MsgBox"Selectedcolor:"&hex(color) functionOpenColor(initColor,flags) setcomdlg=CreateObject("MSComDlg.CommonDialog") comdlg.Color=initColor comdlg.Flags=flags comdlg.ShowColor OpenColor=comdlg.Color endfunction 组件相关文件下载。

43人参与, 0条评论 登录后显示评论回复

你需要登录后才能评论 登录/ 注册