Page 1 of 1 1
Topic Options
#211269 - 2016-04-07 04:26 PM Shell.Application, BrowseForFolder()
Lipman Offline
Fresh Scripter

Registered: 2005-05-09
Posts: 43
Loc: Jersey Shore USA
 Code:
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
#211270 - 2016-04-07 05:17 PM Re: Shell.Application, BrowseForFolder() [Re: Lipman]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Based on my googling, I don't think this is going to work for files, despite the appearance that &4000 shows files too. I was able to select a zip file too, likely because windows treats those as archive folders, but was not able to select any other type of file.

Here was a good article that was basically the same question as yours. http://stackoverflow.com/questions/28632270/vbscript-file-or-folder-selection

Top
#211271 - 2016-04-07 05:25 PM Re: Shell.Application, BrowseForFolder() [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Appears it worked at one time but was broke, and has never been fixed.
http://www.kixtart.org/forums/ubbthreads...=true#Post83860

Top
#211273 - 2016-04-07 06:22 PM Re: Shell.Application, BrowseForFolder() [Re: Allen]
Lipman Offline
Fresh Scripter

Registered: 2005-05-09
Posts: 43
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 Offline
Fresh Scripter

Registered: 2005-05-09
Posts: 43
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 (1019 downloads)
Description:




Edited by Allen (2016-04-08 04:13 AM)

Top
#211277 - 2016-04-08 04:12 AM Re: Shell.Application, BrowseForFolder() [Re: Lipman]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
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
#211278 - 2016-04-08 04:24 AM Re: Shell.Application, BrowseForFolder() [Re: Allen]
Lipman Offline
Fresh Scripter

Registered: 2005-05-09
Posts: 43
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
#211279 - 2016-04-08 04:27 AM Re: Shell.Application, BrowseForFolder() [Re: Lipman]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Using Postprep and html coding.
Top
#211280 - 2016-04-08 06:29 AM Re: Shell.Application, BrowseForFolder() [Re: Allen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
 Code:
  
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
#211281 - 2016-04-08 06:51 AM Re: Shell.Application, BrowseForFolder() [Re: NTDOC]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Yep, seems to be broken here. Works on the UBBCentral main site as they have the latest version but it has word wrap enabled in code tags. I've asked if it's possible to disable the word wrap from within the software vs an external css or other config file.
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 370 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.165 seconds in which 0.136 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org