Solved

VBSCRIPT something link BrowseForFile as BrowseForFolder

Posted on 2004-03-21
8
4,236 Views
Last Modified: 2007-12-19
Is there any way to display a "BrowseForFile" dialog, similar to the
  BrowseForFolder method of the shell object?  I am
  looking for a way to allow the user to select a FILE or a FOLDER

  Is this possible in VBScript?
0
Comment
Question by:hasnut
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10645246
If you mean in a web page you just need HTML:

<form>
<input type="file">
</form>

Cd&
0
 
LVL 1

Author Comment

by:hasnut
ID: 10645302
HI HI,
So, can I select Folder?

Option Explicit

Const SerSetRoot_desktop            = 0    
Const SerSetRoot_programs           = 2    
Const SerSetRoot_controlpanel       = 3    
Const SerSetRoot_printers           = 4    
Const SerSetRoot_documents          = 5    
Const SerSetRoot_favorites          = 6    
Const SerSetRoot_startup            = 7    
Const SerSetRoot_recent             = 8    
Const SerSetRoot_sendto             = 9    
Const SerSetRoot_startmenu          = 11  
Const SerSetRoot_drives             = 17  
Const SerSetRoot_network            = 18  
Const SerSetRoot_nethood            = 19  
Const SerSetRoot_fonts              = 20  
Const SerSetRoot_templates          = 21

Code 1 End

Here in code 1 we see we can set root as we like. Those are the constant values.

 

 Code 2 Starts

Function BrowseForAnything(ShowText, BrowseInformation, SetRoot)
 On Error Resume Next
 Dim AppShell, ReturnFolder,  WshShell, errorcode,ColonPosition

 Set AppShell = WScript.CreateObject("Shell.Application")
 Set WshShell = CreateObject("WScript.Shell")

 Set ReturnFolder = AppShell.BrowseForFolder(&H0, ShowText, BrowseInformation, SetRoot)
 BrowseForAnything = ReturnFolder.ParentFolder.ParseName(ReturnFolder.Title).Path
 

   errorcode = err.number
 
   If errorcode <> 0 Then
 If errorcode = 424 then
  BrowseForAnything = Null
     else
   
      ColonPosition = InStr(ReturnFolder.Title, ":")

          If ColonPosition > 0 Then
    BrowseForAnything = Mid(ReturnFolder.Title, ColonPosition - 1, 2) & "\"
       End If
 End If
    End If
End Function


I need: if file is selected then return value should be the file path+file name
if directory selected then show the Directory/folder path (ITS ALLREADY THERE)

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10645472
I have no idea what you are trying to do.  I don't use vbscript. From what I can see though, if it runs at all on a web page it is going to throw all kind so security alerts and a lot of fire walls will block it.

If you are trying to preset the path the user goes to, you will have a hard time, because the browser has specific security routines to prevent that.

Cd&
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 1

Author Comment

by:hasnut
ID: 10645478
Just rename it vbs and run it. You will see the Browse for Folder Window, I have the asp code of this.

0
 
LVL 1

Author Comment

by:hasnut
ID: 10652436
INTERESTING NO ONE ANSWERING MY QUESTION? If anyone interested I can give you much big points
0
 
LVL 3

Expert Comment

by:domj
ID: 12158076
No, you cannot select a File in the same way that you select the folder. Trust me, I have spent a long time trying to do it. The best you could do is display a list of the files in the directory selected.

Dom
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 12580045
PAQed with no points refunded (of 100)

GhostMod
Community Support Moderator
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question