Wshshell. Run method description

Source: Internet
Author: User
[Vbs] wshshell. Run method description

Run method description:

Object. Run (strcommand, [intwindowstyle], [bwaitonreturn]) parameter
Object
Wshshell object.
Strcommand
The string value of the command line to be run. All parameters to be passed to the executable file must be included.
Intwindowstyle
Optional. IndicatesProgramThe integer of the window appearance. Note that not all programs use this information.
Bwaitonreturn
Optional. Boolean value, indicating whether the script is waiting for the execution of the program before continuing to execute the next statement in the script. If it is set to true, the script is executed only after the program is executed. The run method returns any errors returned by the program.Code. If it is set to false (default), the run method automatically returns 0 (not the error code) immediately after the program is started ).
Description
The run method returns an integer. Run method to start the program running in the new windows process. The script can be executed after the program is executed. This allows you to run scripts and programs synchronously. The environment variables in the strcommand parameter are automatically extended. If a file type has been correctly registered to a program, the program will be executed when the run method is called for this type of file. For example, if a word is installed in your computer system, the *. DOC file will be started and loaded when the run method is called. The following table lists the available settings of intwindowstyle.

Intwindowstyle description
0. Hide a window and activate another window.
1. Activate and display the window. If the window is in the minimized or maximized state, the system restores it to the original size and position. When this window is displayed for the first time, the application should specify this flag.
2. Activate the window and display it as a minimal window.
3. Activate the window and display it as the maximum window.
4. display the window according to the size and position of the nearest window. The activity window remains active.
5. Activate the window and display it according to the current size and position.
6. Minimize the specified window and activate the next top window in Z sequence.
7. display the window as a minimal window. The activity window remains active.
8. The window is displayed as the current status. The activity window remains active.
9. Activate and display the window. If the window is in the minimized or maximized state, the system restores it to the original size and position. This flag should be specified by the application when the minimization window is restored.
10. Set the display status based on the program status when the application is started.

For more information about wshshell objects, see msdn

Example 1
The following VBScript Code uses notepad to open a copy of the currently running script.

Set wshshell = wscript. Createobject ("wscript. Shell ")
Wshshell. Run "% WINDIR %/Notepad" & wscript. scriptfullname
The following VBScript code is the same as the operation completed by the above Code. The difference is that it specifies the window type, waits for the user to close notepad, and saves the error code returned from notepad when closing notepad.

Set wshshell = wscript. Createobject ("wscript. Shell ")
Return = wshshell. Run ("Notepad" & wscript. scriptfullname, 1, true)
Example 2
The following VBScript code opens a command window, changes the path to C:/, and runs the Dir command.

Dim oshell
Set oshell = wscript. Createobject ("wscript. Shell ")
Oshell. Run "CMD/k cd c:/& dir"
Set oshell = nothing

Example 3
VaR wsh = new activexobject ("wscript. Shell ");
Wsh. Run ("% WINDIR % // notepad.exe C: // docs // readme.txt ");
Pass in the correct command line in the run method to execute the corresponding command

[From]
Http://bbs.huistd.com/detail.php? Pagenum = 0 & id = 1509
Http://ithomecn.com/soft/p273/A27333569.shtml

Http://www.trucy.org/blog/sheryl/archives/2007/12/vbswshshellrune.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.