In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Createobject ("wscript.shell") .run "" BAT or EXE file path and name "", 0 true
0 means to hide the running window
True indicates whether the script waits to finish executing the run and exec methods of the program WScript.Shell object before continuing to execute the next statement in the script: Function Exec (ByVal Command As String) As WshExecFunction Run (ByVal Command As String, [ByVal WindowStyle], [ByVal WaitOnReturn]) As Integer difference: 1. The return value of run is an integer, that is, 0 or 1 success and failure, while the return value of the exec method is an object Console output information and console error messages, such as StdOut and StdErr properties, can be obtained from the returned object. For example: Dim oShell,exeRsSet oShell = CreateObject ("WSCript.shell") commandLine = "xcopy.exe" Set exeRs = oShell.Exec (commandLine) errMsg = exeRs.StdErr.ReadAll () stdMsg = exeRs.StdOut.ReadAll () WScript.echo "errMsg:" & errMsg & "stdMsg:" & stdMsgret = oShell.run (commandLine, 0, true) WScript.echo "run method return value:" & retSet oShell = NothingSet exeRs = Nothing can take console errors and console messages. Note: the WshExec class has an attribute ExitCode,ProcessID,Status,StdErr,StdIn,StdOut and a function Terminate, which are easy to understand. The Status property has three values: Const WshFailed = 2Const WshFinished = 1
Const WshRunning = 0
2. The last two parameters of the execution parameter Run, one is the style of the cmd window, and the other is whether to wait for the execution to be completed. The last parameter is very useful, if you want to wait for the end of the cmd execution of the program, then execute the statement after run, set this parameter to true, otherwise the later statement will not wait for the completion of the cmd window, run directly. In addition, if you use the exec method, if you want to wait for the execution of the cmd program, and then execute the following statements, you can also use the following method: oExec.StdErr.ReadAll () or oExec.StdOut.ReadAll (), the reason should also be easy to understand, to get the output information, there must be cmd execution before there will be output. The parameter set WshShell= CreateObject ("Wscript.Shell") WshShell.run "notepad.exe", the run function, takes three arguments. The first parameter is the path of the program you want to execute. If there is a space in the path, remember to enclose it with "", such as "C:\ Program Files\ nn.exe" or Chr (34) & "C:\ Program Files\ nn.exe" & Chr (34). The second program is in the form of a window, and 0 runs in the background. 1 indicates normal operation; 2 indicates that the program is activated and displayed as minimized; 3 indicates that the program is activated and is displayed as maximized; there are a total of 10 such parameters as shown in the table below. The third parameter indicates whether the script will wait or continue to execute. If set to true, the script will wait for the calling program to exit before executing backwards. In fact, as a function, run is preceded by a variable that accepts the return value. Generally speaking, if the return value is 0, it means successful execution. If it is not 0, then the return value is the error code, and the corresponding error can be found through this code. IntWindowStyle description 0 hides one window and activates another. 1 activate and display the window. If the window is minimized or maximized, the system restores it to its original size and position. The first time the window is displayed, the application should specify this flag. 2 activate the window and display it as a minimized window. 3 activate the window and display it as a maximized window. 4 display the window according to the nearest window size and position. The active window remains active. 5 activate the window and display it at its current size and position. 6 minimize the specified window and activate the next top window in Z order. 7 displays the window as a minimized window. The active window remains active. 8 displays the window as its current state. The active window remains active. 9 activate and display the window. If the window is minimized or maximized, the system restores it to its original size and position. The application should specify this flag when restoring the minimized window. 10 sets the display status according to the program status of the startup application.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.