File actions
Copy Code code as follows:
Set FSO = WScript.CreateObject ("Scripting.FileSystemObject") ' Creates file system objects to work with drives, folders, and files
Set WshShell = WScript.CreateObject ("Wscript.Shell") ' Creates system Shell objects to run programs and so on
If Fso.fileexists ("D:\ Sword Online\alreadyexist.txt") Then ' if found file ' D:\ Sword online\alreadyexist.txt '
Wshshell.run ("D:\ Sword online\ Sword Online.exe") ' Run ' D:\ Sword online\ Sword Online.exe "
ElseIf fso.fileexists ("\\gengxin\update\dj.exe") then ' otherwise, if "\\gengxin\update\dj.exe" is found
Wshshell.run ("\\gengxin\update\dj.exe") ' Run ' \\gengxin\update\dj.exe '
Else
Wshshell.run ("D:\ Sword online\ Sword Online.exe") "Otherwise run" D:\ Sword online\ Sword Online.exe "
End If ' Execute a statement based on a condition
VBS to import the registry, and then execute the file
Copy Code code as follows:
Dim Wsh Set Wsh = WScript.CreateObject ("Wscript.Shell")
Wsh.regwrite "Hkcu\software\audition\autostart", 0, "REG_DWORD"
Wsh.regwrite "Hkcu\software\audition\path", "G:\ network game \ Dance Group 1.5", "REG_SZ"
Wsh.regwrite "Hkcu\software\audition\version", 1010, "REG_DWORD" Wsh.run "Patcher.exe"
Ping network does not pass on the shutdown of the VBS
Copy Code code as follows:
StrIP = "192.168.0.254" ' Ping intranet Machine
Set Objshell = CreateObject ("Wscript.Shell")
If not Isonline (StrIP) Then objshell.run "shutdown-s-t 30-c" &CHR () & "Machine is about to close" &CHR (34)
End If
Function isonline (strComputer) Isonline = False strcommand = "%comspec%/C ping-n 2-w" & StrComputer & "" S ET objexecobject = objshell.exec (strcommand) do, not objExecObject.StdOut.AtEndOfStream StrText = ObjExecObject.StdOut.ReadAll () If Instr (StrText, "Reply") > 0 Then isonline = True End If Loop end Function
Boot script vbs for ARP bonding
Copy Code code as follows:
Set WshShell = WScript.CreateObject ("Wscript.Shell")
Wshshell.run "Arp-s 192.168.0.1 30-18-e5-33-01", 0
Wshshell.run "Arp-s 192.168.0.5 30-18-e5-33-07", 0
Running programs
Copy Code code as follows:
Dim A
Set Wsh = WScript.CreateObject ("Wscript.Shell")
A.run "D:\ network game, Dahua West Tour Ii\xy-2.exe"
Run Oshell.run "D:\soft\hf\hfgame3\GameClient.lnk"
Disconnect from Network
Copy Code code as follows:
Strnicname = "Disable =net pci\*"
Set Objshell = CreateObject ("Wscript.Shell")
strcommand = "Devcon.exe" & Strnicname
Objshell.run strcommand, 0, False
Start Network connection
Copy Code code as follows:
Strnicname = "Enable =net pci\*"
Set Objshell = CreateObject ("Wscript.Shell")
strcommand = "Devcon.exe" & Strnicname
Objshell.run strcommand, 0, False
Delete a VBS script for a file
Copy Code code as follows:
Dim fso Set FSO = CreateObject ("Scripting.FileSystemObject")
Fso. CopyFile "\\server\ shared \xxx.lnk", "C:\ Target location 1\", true "add
Fso. CopyFile "\\server\ shared \xxx.lnk", "C:\ Target location 2\", true "add
Fso. DeleteFile "C:\ Target location 1\xxx.lnk", True ' remove FSO. DeleteFile "C:\ Target location 2\xxx.lnk", True ' delete
Set fso=nothing Wscript.Quit
No interface automatic detection of iSCSI client installation, mapping and fracture mapping VBS script
The following code implements the no interface Automatic detection installation iSCSI client, automatic mapping
Copy Code code as follows:
On Error Resume Next setupfile= "Iscsi2.0.exe" iSCSI Client Installation file path
Serverip= "192.168.0.100" iSCSI server IP
Set oshell= CreateObject ("Wscript.Shell")
Set fso = CreateObject ("Scripting.FileSystemObject")
If not fso.fileexists (Oshell. ExpandEnvironmentStrings ("%WinDir%") + "\system32\iscsicpl.cpl")
Then Oshell.run setupfile& "/q", 1
End If
Oshell.run "iscsicli addtargetportal" &serverip& "3260", 0,1
The following example code implements a no-interface delete iSCSI map disk
Copy Code code as follows:
filetmp= "C:\my.txt"
On Error Resume Next
Set Shell = CreateObject ("Wscript.Shell")
Set FSO = WScript.CreateObject ("Scripting.FileSystemObject")
Shell.run "cmd/c iscsicli sessionlist>" &filetmp,0,1
Const ForReading = 1
Dim FSO, Thefile, retstring
Set fso = CreateObject ("Scripting.FileSystemObject")
Set thefile = fso. OpenTextFile (filetmp, ForReading)
Aaa=thefile.readall
Thefile.close
function Myreadline ()
X=instr (1,aaa,vbcrlf,vbtextcompare)
Myline=mid (aaa,1,x-1)
Aaa=right (Aaa,len (AAA)-X)
If Len (AAA) =<1 then Myline = "End"
Myreadline=myline
End Function
Do While bbb<> "End"
Bbb=myreadline
If BBB <> "End" then
If BBB <> "" Then
If InStr (BBB, "session") <>0 then
Temid=mid (Bbb,instr (BBB, ":") +1,len (BBB)-instr (BBB, ":"))
Shell.run "iscsicli Logouttarget" &temid,0
End If
End If
End If
Loop
Fso.deletefile (FILETMP)
Delete QQ user files Forced deletion is not a good thing to skip the words like this:
Copy Code code as follows:
Dim FSO, Folderspec, F, F1, FC
Folderspec = "F:\Program files\tencent\qq" ' Set Up your QQ folder
Dim Re
Set Re = New RegExp
Re.pattern = "^\d{4,13}$"
Set fso = CreateObject ("Scripting.") FileSystemObject ")
Set f = fso. GetFolder (FOLDERSPEC)
Set FC = F.subfolders
For each F1 in FC If Re.test (f1.name) Then
On Error Resume Next
F1. Delete (True)
On Error GoTo 0
End If
Next
Grid 5 minutes To run a batch program
Copy Code code as follows:
Dim Wsh
Set Wsh = WScript.CreateObject ("Wscript.Shell")
Do Wsh.run "D:\aaa.bat" ' The batch you want to perform
Wscript.Sleep (300000)
Loop
To set up automatic operation, prohibit the program