Lipman
(Fresh Scripter)
2016-04-07 04:26 PM
Shell.Application, BrowseForFolder()

 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.




AllenAdministrator
(KiX Supporter)
2016-04-07 05:17 PM
Re: Shell.Application, BrowseForFolder()

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


AllenAdministrator
(KiX Supporter)
2016-04-07 05:25 PM
Re: Shell.Application, BrowseForFolder()

Appears it worked at one time but was broke, and has never been fixed.
http://www.kixtart.org/forums/ubbthreads...=true#Post83860


Lipman
(Fresh Scripter)
2016-04-07 06:22 PM
Re: Shell.Application, BrowseForFolder()

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 }



Lipman
(Fresh Scripter)
2016-04-08 03:53 AM
Re: Shell.Application, BrowseForFolder()

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)


AllenAdministrator
(KiX Supporter)
2016-04-08 04:12 AM
Re: Shell.Application, BrowseForFolder()

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


Lipman
(Fresh Scripter)
2016-04-08 04:24 AM
Re: Shell.Application, BrowseForFolder()

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 ?




AllenAdministrator
(KiX Supporter)
2016-04-08 04:27 AM
Re: Shell.Application, BrowseForFolder()

Using Postprep and html coding.

NTDOCAdministrator
(KiX Master)
2016-04-08 06:29 AM
Re: Shell.Application, BrowseForFolder()

 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

 


NTDOCAdministrator
(KiX Master)
2016-04-08 06:51 AM
Re: Shell.Application, BrowseForFolder()

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.