Home > Software engineering >  VBS input box input of delivery to 1. The bat. How to do
VBS input box input of delivery to 1. The bat. How to do

Time:09-20

The contents of the bat is youtube - dl
I want to write a VBS input box, the contents of the input in the input box, integrate into the bat, let new bat to run,

CodePudding user response:

Fyi:
 script code below to open a command window, change the path to C: \, and perform the DIR command, 

Dim oShell
The Set oShell=WScript. CreateObject (" WScript. Shell ")
OShell. Run "CMD/K CD C: \ & amp; Dir "
The Set oShell=Nothing

CodePudding user response:

The Windows script host

Run method
Please refer to the
WshShell object
In the new process to run the program,

Object. The Run (strCommand, [intWindowStyle], [bWaitOnReturn])
Parameter
The object
WshShell object,
StrCommand
Said to run the command line string value, must include all the parameters to pass to the executable file,
IntWindowStyle
Optional, said the program window appearance of integer values, please note that not all applications using this information,
BWaitOnReturn
Optional, Boolean, said before the next statement in the continue to execute the script, the script is waiting for the execution of the program, if set to true, then the execution of the program after executing the script to Run method returns any error code returned by the program, if set to false (default), the Run method will automatically be immediately after the start the program returns 0 (not the error code),
Description
Run method returns an integer, the Run method starts in the process of new Windows operation program, can let the script continue until after the program execution again, this allows you to synchronize running scripts and programs, strCommand parameters within the environment variables automatically expand, if a file type has been correctly registered to a program, is for the type of file to invoke the Run method will execute the program, for example, if your Word, are installed in the computer system for *. Doc file to invoke the Run method will start the Word and load the document, the following table lists the intWindowStyle Settings available,

IntWindowStyle description
0 a hidden window and activates another window,
1 activation and display window, if the window is minimized or maximized state, then the system restore to its original size and position, shows the window for the first time, the application should specify this flag,
2 activation window and displays it to minimize window,
3 activation window and displays it to maximize window,
4 at the most recent window size and position display window, the active window remains active state,
5 the activation window and displays it by current size and position,
6 minimizes the specified window, and activate the next at the top of the window, in the Z order
7 will display window to minimize window, the active window remains active state,
8 the window display for the current state, the active window remains active state,
9 activated and display window, if the window is minimized or maximized state, then the system restore to its original size and location, reducing minimize window, the application should specify this flag,
10 according to start the application program state to set the display status,

Example 1
The following script code use notepad to open a copy of the currently running script,

The Set WshShell=WScript. CreateObject (" WScript. Shell ")
WshShell. Run "% windir % \ notepad" & amp; WScript. ScriptFullName
The following script code is the same with the code to complete the operation of the above, the difference is that it specifies the window type, waiting for the user closes the notepad, when close notepad save from notepad return an error code,

The Set WshShell=WScript. CreateObject (" WScript. Shell ")
Return=WshShell. Run (" notepad "& amp; WScript. ScriptFullName, 1, true)
Example 2
The VBScript code below to open a command window, change the path to C: \, and perform the DIR command,

Dim oShell
The Set oShell=WScript. CreateObject (" WScript. Shell ")
OShell. Run "CMD/K CD C: \ & amp; Dir "
The Set oShell=Nothing
Please refer to the
WshShell object



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

? 2001 Microsoft Corporation. All rights reserved,

CodePudding user response:

 Set VBS=CreateObject (" Wscript. Shell ") 
VBS. Run "CMD"
Wscript. Sleep 1000
VBS. SendKeys "youtube - dl"

This is a
Can also be generated BAT file and then run
 
The set of fso=createobject (" scripting. Filesystemobject ")
Set the ws=CreateObject (" wscript. Shell ")
The set fw=fso. Createtextfile (" 1. Bat ", 2)
Fw. Writeline (" youtube - dl ")
Fw. Close
Ws. Run "1. Bat"

This will generate a file and then run.
  • Related