Seleccionar un archivo con VBScript

Con este méto­do, podremos selec­cionar archivos con nue­stro VBScript, lo hare­mos hacien­do una lla­ma­da a Inter­net Explor­er, y este nos dara la ruta del archi­vo (sin el fakepath).

- Abri­mos el Bloc de Notas
— Copi­amos este texto:

Set WshShell = CreateObject("WScript.Shell")
On Error Resume Next
incluir1 = WshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\160A")
On Error Resume Next
incluir2 = WshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\CurrentLevel")
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\160A", "0", "REG_DWORD"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\CurrentLevel", "0", "REG_DWORD"

Dim Result
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Vis­i­ble = False
.Navigate("about:blank")
Do Until .ReadyS­tate = 4 : Loop
With .Doc­u­ment
.Write "<html><body><input id='f' type='file'></body></html>"
With .All.f
.Focus
.Click
Result = .Val­ue
End With
End With
.Quit
End With
Set IE = Nothing

Msg­Box Result

If incluir1 <> "" Then
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\160A", incluir1, "REG_DWORD"
End If
If incluir2 <> "" Then
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\CurrentLevel", incluir2, "REG_DWORD"
End If

- Lo guardamos con exten­sión ".vbs"

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

+ 25 = 35