2017-08-01 93 views
1

我一直在试图找到写一个VBScript,让我找到一个文件路径,然后插入它的位置到文件──test.txt文件VBScript中查找路径的文件夹,然后输入路径转换成文本TXT文件

例如:

点击Find.vbs

窗口中打开搜索文件夹或驱动

选择C:\ test文件夹

你确定要选择c:\ test文件夹吗?在文件──test.txt文件

字driveselect更改为C提示

点击Yes按钮

:\测试

,我发现这个打开的窗口中,然后让我选择文件,它然后打开一个msgbox显示文件名,但不会选择一个文件夹只有

Set wShell=CreateObject("WScript.Shell") 
Set oExec=wShell.Exec("mshta.exe ""about:<input type=file id=FILE> 
<script>FILE.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);</script>""") 
sFileSelected = oExec.StdOut.ReadLine 
wscript.echo sFileSelected 

那里是我发现改变文字文件中的文本的几个代码,但不包含带有输入的文本文件。

任何帮助将不胜感激。

谢谢

回答

0

您可以使用Excel应用程序的FileDialog来选择文件夹。

Dim FolderName, msg, msgResponse 

Do 
    FolderName = getSelectedFolderPath 
    msg = "Are you sure you want to select " & vbCrLf & FolderName & "?" 
    msgResponse = MsgBox(msg, vbYesNo,"") 
Loop Until Len(FolderName) = 0 Or msgResponse = vbYes 

Function getSelectedFolderPath 
    Const msoFileDialogFolderPicker = 4 
    Dim xlApp 
    Set xlApp = CreateObject("Excel.Application") 
    With xlApp.FileDialog(msoFileDialogFolderPicker) 
     .Show 
     If .SelectedItems.Count > 0 Then 
      getSelectedFolderPath = .SelectedItems(1) 
     End If 
    End With 
    xlApp.Quit 
End Function