#211269 - 2016-04-07 04:26 PM
Shell.Application, BrowseForFolder()
|
Lipman
Getting the hang of it
Registered: 2005-05-09
Posts: 52
Loc: Jersey Shore USA
|
Function BrowseForFile()
dim $obj,$strPath,$STR
$STR=@crlf+"Choose the Password Protected Archive file..."+@crlf+@crlf
$obj = CreateObject("Shell.Application")
$strPath = $obj.BrowseForFolder(0,$STR,&4000,"")
$BrowseForFile = $strPath.self.Path
EndFunction
I created the above function. However I am not getting the expected results and I believe the selection of type represented by "&4000" is the culprit.
When I use BrowseForFile() and browse to a ZIP file I get the Fully Qualified Name and Path (FQNP) of the ZIP file that was selected.
However, when I use BrowseForFile() and browse to a 7z or RAR file I get a null string.
I need BrowseForFile() to provide the FQNP of any file I select.
|
|
Top
|
|
|
|
#211273 - 2016-04-07 06:22 PM
Re: Shell.Application, BrowseForFolder()
[Re: Allen]
|
Lipman
Getting the hang of it
Registered: 2005-05-09
Posts: 52
Loc: Jersey Shore USA
|
Thanx...
It is really weird because I originally tested it with a file that was named "ThisFile.PDF" but was in reality "ThisFile.ZIP". Thus I thought all was well.
The original objective is to use a GUI to select a password protected ZIP file and to then use a library of known passwords. Then extract the files and note the successful password.
That all works.
However I wanted to expand its scope to other Archive Files types and to use UNRAR.EXE and 7za.exe to do likewise with password protected RAR and 7zip files.
That's when I realized when I chose them, I was getting a NULL String.
Any other ideas for a GUI based file selection ? [ not KiXforms ]
RE: GUIDialog() - GUI dialog for selecting folder, file, printer or computer Almost 10 years ago. I don't even remember being in that thread. { Oy Vey }
|
|
Top
|
|
|
|
#211276 - 2016-04-08 03:53 AM
Re: Shell.Application, BrowseForFolder()
[Re: Lipman]
|
Lipman
Getting the hang of it
Registered: 2005-05-09
Posts: 52
Loc: Jersey Shore USA
|
I found a solution. It just needs some tweaking. such as the default text in the dialogue "Choose File to Upload"
The only problem is this Forum software is interpreting the script even though it is in Code Tags. therefore I have attached the SelectFile( ) function in the attached KiX Script.
(edit: removed code, causing issues with forums, see next post for code)
Attachments
TEST.KiX (1272 downloads) Description:
Edited by Allen (2016-04-08 04:13 AM)
|
|
Top
|
|
|
|
#211278 - 2016-04-08 04:24 AM
Re: Shell.Application, BrowseForFolder()
[Re: Allen]
|
Lipman
Getting the hang of it
Registered: 2005-05-09
Posts: 52
Loc: Jersey Shore USA
|
Thanx Allen.
I had informed NTDOC about the code interpretation and another issue.
So how were you able to post the function w/o it getting interpreted ?
|
|
Top
|
|
|
|
#211280 - 2016-04-08 06:29 AM
Re: Shell.Application, BrowseForFolder()
[Re: Allen]
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: CA
|
Function SelectFile( )
Dim $objSHELLexec, $CMD, $objSHELL
$SelectFile=""
$CMD='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>" '
$objSHELL=CreateObject("WScript.Shell")
$objSHELLexec=$objSHELL.Exec($CMD)
$SelectFile=$objSHELLexec.StdOut.ReadLine( )
EndFunction
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 661 anonymous users online.
|
|
|