![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-01 23:14 |
48,037 topics / 350,122 posts / today 2 new / 48,250 members |
| DOS批处理 & 脚本技术(批处理室) » How to call a VBS dialog in the DOS command line |
| Printable Version 1,778 / 9 |
| Floor1 hdshjffdd | Posted 2006-07-31 15:05 |
| 初级用户 Posts 53 Credits 131 | |
|
set objFile = CreateObject("SAFRCFileDlg.FileOpen")
intRet = objFile.OpenFileOpenDlg wscript.echo intRet, objFile.FileName How to add the selected file to the variable of the command line for calling? |
|
| Floor2 3742668 | Posted 2006-08-01 12:23 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
Save the above code as: Open File.vbs
If you just want to display the file name, it is recommended to modify the last line of the vbs script to Wscript.StdOut.Write objFile.FileName. Although the effect of using the echo method of wscript and the write method of the wscript.stdout object seems the same, it is recommended that scripts parsed with cscript should preferably use the latter to control the output stream. |
|
| Floor3 zh159 | Posted 2006-08-01 16:55 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
Referring to the building - block's VBS script, how to expand it to open multiple files at one time and output the absolute path of each file, as well as obtain the file name of each one separately?
|
|
| Floor4 3742668 | Posted 2006-08-01 22:00 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
Regarding selecting multiple files at once, the only method provided by Microsoft officially is to specify the flags property of the UserAccounts.CommonDialog object. For example:
As for how to call and output the result in batch processing, the method is still the same as in 2F. |
|
| Floor5 zh159 | Posted 2006-08-01 22:47 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
Thanks to the moderator of version 3742668 for the explanation.
In addition, the absolute path I obtained is like: "D:\AAA\BBB\CCC.txt". How to separately extract the file name (that is, remove the path, and the path may not be the same) in the batch processing? But both the absolute path and the separate file name need to be used in two sets of data. |
|
| Floor6 3742668 | Posted 2006-08-01 22:57 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
For variable expansion usages like %~ni, please check for /? carefully.
|
|
| Floor7 zh159 | Posted 2006-08-01 23:21 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
Does the script on floor 4 have to input at least two files each time, and can't it input one or more?
|
|
| Floor8 zh159 | Posted 2006-08-02 10:57 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
Also: The script on the 4th floor cannot input long file names containing spaces
|
|
| Floor9 3742668 | Posted 2006-08-02 11:39 |
| 荣誉版主 Posts 718 Credits 2,013 | |
|
1. For the case of selecting at least two files, you can add an if statement by yourself to judge. How much improvement can there be just by copying others' code?
2. It's not that you can't input long file names with spaces, but that the long file names are automatically replaced with 8.3 short names. |
|
| Floor10 zh159 | Posted 2006-08-02 12:58 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
Originally posted by 3742668 at 2006-8-2 11:39: What I'm saying is calling VBS multiple times, inputting single or multiple files in the input box 1、 set objFile = CreateObject("SAFRCFileDlg.FileOpen") This can only input a single file each time 2、 Set objDialog = CreateObject("UserAccounts.CommonDialog") And this can only input at least two files each time, not single ones If you modify some parameters, you can input a single file alone, but when inputting two or more, there will be N+1 variables, and the first one is empty In addition: Can the second one not automatically replace the long file name with the 8.3 short name? |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |