CodePudding user response:
I know that should use the bat file, need to write the scriptCodePudding user response:
If you want to use IE to open the web page, use the DOS command, just like this:"C: \ Program Files \ Internet Explorer \ iexplore exe" www.baidu.com
CodePudding user response:
That is, write the words of command. The bat or the CMD file, can all,CodePudding user response:
If you want to call an external command or program, using VB to realize VB offers a Shell function, usage:The Shell "CMD ping 127.0.01/p"
Shell also supports a parameter, is displays the command, whether called program and activate the window display
System apis, of course, also provides a more intelligent for VB API function trigger call external programs, that is ShellExecute
Usage:
ShellExecute 0, "OPEN", "command path", "command parameter", "command to initialize the path", 5
The location of the first parameter to 0 is to specify the parent window handle, if there is no parent window, can be set to 0, said the desktop to the parent window
The second parameter "OPEN", actually support is not only the parameters, this just OPEN the specified file specified system options, also support the
Runas, print, edit, explore, find and so on, but it is ok to call external files with open,
Last parameter in recent 5 said the size and location of the display and activate the caller of the main window, you can also set to 0 hidden call program interface
Example:
ShellExecute 0, "OPEN", "notepad. Exe", "c: \ Windows \ system. Ini", "c: \ Windows", 5
So you can use notepad to open the system directory system. Ini file
Is said to be more intelligent interface, it is because the API support file open, can even do not open the file specified application, such as:
ShellExecute 0, "OPEN", "c: \ Windows \ system. Ini", ""," c: \ Windows ", 5
This directly with no parameters to open the target file is written to open the target, then the system will according to the ini file associations choose our applications to open the file,
Here you can imagine, if the goal in open input is the url is what phenomenon?
Results will certainly not surprisingly calls the system default browser to open the url, such as:
ShellExecute 0, "OPEN", "http://www.baidu.com", ""," c: \ Windows ", 5
If you have a series of external command needs to be executed in sequence, there is a simple approach is batch,
You can use the VB Open statement to write files to the batch file,
Then use the Shell or ShellExecute function API to call the batch file is ok,
Such as:
Open "C: \ TMP. Bat" For Output # 1
Print # 1, md, c: \ "test", "
Print # 1, "copy c: \ Windows \ system. Ini c: \ test \."
Print # 1, "del c: \ TMP. Bat" 'this is processed to remove
Close # 1
The Shell "C: \ TMP. The bat," 5
Much, of course, this method will cause slight injury to the hard disk, but fortunately, simple processing,
Actually can also use the monitoring for the Shell or ShellExecute complete approach to achieve this process, but a little more complicated, but is also more than 6-7 lines of code to ten lines of code, just basic API is used to implement, if you are interested can search and see,
CodePudding user response:
Generally use the shell's enoughA special case with ShellExecute
CodePudding user response:
BAT, VBS, as long as dare to think,CodePudding user response:
As far as possible to try some other methodsCodePudding user response:
Recommend the original poster autoruns using software