opening a directory dialogbox.... 
Author Message
 opening a directory dialogbox....

hi

is it possible to open a file dialogbox in which i can select only
directories from js...using the WScript Host ?

thx



Sat, 03 May 2003 03:00:00 GMT  
 opening a directory dialogbox....
You can use the function below. Note that it calls itself if you select
a virtual folder such as Printers or My Computer.

function BrowseForFolder()
{
    try {var Shell = new ActiveXObject("Shell.Application");}
    catch(Shell)
    {
        WScript.Echo("Unable to create needed Shell object");
         return false;
    }
    try
    {
        var Folder = Shell.BrowseForFolder(0,"Select folder",0,17);
        var Title = Folder.Title.indexOf(":)") == - 1 ?
              Folder.Title : Folder.Title.match(/[a-z]:/i)[0] + "\\";
        var Path = Folder.ParentFolder.ParseName(Title).Path;
    }
    catch(Path)
    {
       return Path.number == -2146827864 ? 0 : BrowseForFolder();
    }
    return Path;

Quote:
}



|
| hi
|
| is it possible to open a file dialogbox in which i can select only
| directories from js...using the WScript Host ?
|
| thx
|
|
|


Sat, 03 May 2003 03:00:00 GMT  
 opening a directory dialogbox....

thanks a lot...

i'm new to scripting with the Windows Scripting Host.
Can you name me a good source for learning ?
or where can get infos about the Objects..i didnt findt anything about the
Shell Object. Is it an AxtiveXComponent or an WSript Object....a man so many
questions...

thanks a lot
karim

Quote:
----- Original Message -----

Newsgroups: microsoft.public.scripting.jscript
Sent: Tuesday, November 14, 2000 3:02 PM
Subject: Re: opening a directory dialogbox....

> You can use the function below. Note that it calls itself if you select
> a virtual folder such as Printers or My Computer.

> function BrowseForFolder()
> {
>     try {var Shell = new ActiveXObject("Shell.Application");}
>     catch(Shell)
>     {
>         WScript.Echo("Unable to create needed Shell object");
>          return false;
>     }
>     try
>     {
>         var Folder = Shell.BrowseForFolder(0,"Select folder",0,17);
>         var Title = Folder.Title.indexOf(":)") == - 1 ?
>               Folder.Title : Folder.Title.match(/[a-z]:/i)[0] + "\\";
>         var Path = Folder.ParentFolder.ParseName(Title).Path;
>     }
>     catch(Path)
>     {
>        return Path.number == -2146827864 ? 0 : BrowseForFolder();
>     }
>     return Path;
> }


> |
> | hi
> |
> | is it possible to open a file dialogbox in which i can select only
> | directories from js...using the WScript Host ?
> |
> | thx
> |
> |
> |



Sat, 03 May 2003 03:00:00 GMT  
 opening a directory dialogbox....
The Shell object is an AxtiveXComponent.

Shell Object
http://msdn.microsoft.com/library/psdk/shellcc/Shell/Objects/Shell/Sh...

BrowseForFolder Method of the Shell Object
http://msdn.microsoft.com/library/psdk/shellcc/shell/Objects/Shell/Br...

Shell Object Special Folder Constants
http://msdn.microsoft.com/library/psdk/shellcc/shell/Objects/Shell/Sh...

Windows Script Host Documentation Download
http://msdn.microsoft.com/scripting/windowshost/wshdoc.exe

JScript Documentation Download
http://msdn.microsoft.com/scripting/jscript/download/jsdoc.exe

VBScript Documentation Download
http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe

Windows Script Components Documentation Download
http://msdn.microsoft.com/scripting/scriptlets/wscdoc.exe

Windows Script Host Whitepaper Download
http://msdn.microsoft.com/scripting/windowshost/docs/reference/whitep...

Windows Script Host Technical Paper
http://msdn.microsoft.com/scripting/windowshost/docs/reference/wshobj...

I tweaked the BrowseForFolder function slightly, although nothing changed in its functionality.

function BrowseForFolder()
{
    try {var Shell = new ActiveXObject("Shell.Application");}
    catch(Shell)
    {
        WScript.Echo("Unable to create needed Shell object");
        return false;
    }
    try
    {
        var Folder = Shell.BrowseForFolder(0,"Select folder",0,17);
        var Title = !/:/.test(Folder.Title) ? Folder.Title :
                    Folder.Title.match(/[a-z]:/i)[0] + "\\";
        return Folder.ParentFolder.ParseName(Title).Path;
    }
    catch(Path)
    {
       return Path.number == -2146827864 ? 0 : BrowseForFolder();
    }

Quote:
}


|
| thanks a lot...
|
| i'm new to scripting with the Windows Scripting Host.
| Can you name me a good source for learning ?
| or where can get infos about the Objects..i didnt findt anything about the
| Shell Object. Is it an AxtiveXComponent or an WSript Object....a man so many
| questions...
|
| thanks a lot
| karim
|
|
|
Quote:
| ----- Original Message -----

| Newsgroups: microsoft.public.scripting.jscript
| Sent: Tuesday, November 14, 2000 3:02 PM
| Subject: Re: opening a directory dialogbox....
|
|
| > You can use the function below. Note that it calls itself if you select
| > a virtual folder such as Printers or My Computer.
| >
| > function BrowseForFolder()
| > {
| >     try {var Shell = new ActiveXObject("Shell.Application");}
| >     catch(Shell)
| >     {
| >         WScript.Echo("Unable to create needed Shell object");
| >          return false;
| >     }
| >     try
| >     {
| >         var Folder = Shell.BrowseForFolder(0,"Select folder",0,17);
| >         var Title = Folder.Title.indexOf(":)") == - 1 ?
| >               Folder.Title : Folder.Title.match(/[a-z]:/i)[0] + "\\";
| >         var Path = Folder.ParentFolder.ParseName(Title).Path;
| >     }
| >     catch(Path)
| >     {
| >        return Path.number == -2146827864 ? 0 : BrowseForFolder();
| >     }
| >     return Path;
| > }


| > |
| > | hi
| > |
| > | is it possible to open a file dialogbox in which i can select only
| > | directories from js...using the WScript Host ?
| > |
| > | thx
| > |
| > |
| > |
| >
| >
|
|
|



Sat, 03 May 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. FileSystemObject and dialogboxes

2. Dialogbox with Checkbox

3. DialogBox "Create a new Folder"

4. Frame open new frame depending of directory

5. Open Directory....What Do You Think?

6. Library Not Registered opening Active Directory Tools and .vbs scripts

7. Conditional Directory Open

8. How do I open a directory in WSH

9. Opening all files of a type in a directory

10. open directory folder window

11. Script opens cmn at incorrect directory

12. How can I open text file for output in the same directory

 

 
Powered by phpBB® Forum Software