[THIN] Re: Published app with restricted file browsing

  • From: "Matthew Shrewsbury" <MShrewsbury@xxxxxxxxxxxxxxx>
  • To: <thin@xxxxxxxxxxxxx>
  • Date: Fri, 11 Nov 2005 09:48:27 -0500

Very nice script but on I'm having one problem. When I double click on a
file to open it, it doesn't open. If I right click and select open it
will open. Any idea why I have to right click to open?

 

Thanks for the script example. I've been looking for something like this
for sometime.

Matthew Shrewsbury, MCSE+Internet MCSE 2000 CCA Server+

Senior Network Administrator

-----Original Message-----
From: thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx] On
Behalf Of Anthony Green
Sent: Friday, November 11, 2005 9:22 AM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Re: Published app with restricted file browsing

 

Copy this script into notepad and save as .vbs

 

It might help you...  Also comes in handy for some other stuff as well
;)

 

To publish it use:           wscript nameoffile.vbs

                        Or:        cscript nameoffile.vbs

 

'START OF SCRIPT

'--This script uses the Shell.App. BrowseForFolder Function

'--as a subsitute For a file browsing window.

'--BrowseForFolder(Hwnd, Title, Options[, Optional Rootfolder])

'-- Hwnd is always 0. Title is browse window caption. RootFolder is
optional top folder to show.

'-- Options has several possibilities:

'--   1 - only allows selection of system folders. (doesn't seem to
work.)

'--   2 - don't show network folders below domain level. (doesn't work
on stand-alone system.)

'--   8 - only allow selection of File System ancestors(??) (on
stand-alone system nothing can be selected.)

'--  16 - adds a text input but only valid entries will be returned;
cannot create a folder.

'--  4096 - only computers can be selected.

'--  8192 - only a printer can be selected.

'--  16384 - full browsing, includes files.

'--  This script uses the FolderItems object properties to Get Path and

'--   find out what type of item it is.

 

'--in addition to returning the selected item path and type, If the item

'--is a folder or file it's also opened and various info. is returned
that's derived

'--from the FolderItem object properties and methods.

 

'---------------------------------------------------------

 

Dim ShellApp, Ret, s, i, sInfo

Set ShellApp = CreateObject("Shell.Application")

 

 On Error Resume Next

Set Ret = ShellApp.BrowseForFolder(0, "Choose file.", 8, "c:\")

 s = Ret.title

  If Err.number <> 0 Then

    MsgBox "Cancelled"

    WScript.Quit

  End If   

 

    s = GetPath(Ret, i, sInfo) '-- Call GetPath Function sending the
object variable

                                       '-- returned from
BrowseForFolder.

                                       '-- i returns type of object.
sInfo returns file or folder info.

                                       

    

    WScript.sleep 500 '--put MsgBox in front of opened file or folder.

                             '-- (unless it's a slow-opening file)

    

      Select Case i

        Case 0

          s = s & " - Namespace"

       Case 1

          s = s & " - Drive"

       Case 2

         s = s & " - Folder" & vbcrlf

       Case 3

         s = s & " - File" & vbcrlf

     End Select         

    MsgBox s & sInfo  '--show full Path and type of item returned.
0-namespace. 1-drive. 2-folder. 3-file.

    Set ShellApp = nothing

    WScript.Quit

 

    

    

 Function GetPath(Fil, iItem, sFI)  

   Dim Pt1, fPar, sn, Obj, sType

       On Error Resume Next

          sn = Fil.title

         Set fPar = Fil.parentfolder

       

      Set Obj = fPar.parsename(sn) '--return item selected as a Shell
FolderItem.

      

       '--weed out namespaces and drives. If it's a namespace or drive
it can't

       '--return a FolderItem so the last Call caused an error and Obj
is therefore

       '--Not part of the filesystem:

       

        If Obj.isfilesystem = false Then

            Pt1 = instr(sn, ":")

             If Pt1 = 0 Then

                 iItem = 0  '--namespace.

                 getpath = sn

             Else

               iItem = 1 '--drive.

               getpath = mid(sn, (Pt1 - 1), 2) & "\"  '--Get letter
before : and add "\" If drive.

             End If  

           Set Obj = nothing  

          exit Function

        End If

           

          '--it's a file or folder. find out which and Get Path.

          '--Then Get FolderItem info.:

        sType = Obj.type  '--Get object Type as shown in folder Details
view.

                           '-- Should be able to use: If Obj.IsFolder =
True..... but it doesn't work.

                

         If instr(sType, "Folder") = 0 Then  '--in detail view a folder
will be type "File Folder".

            iItem = 3  '--file.

         Else

            iItem = 2  '--folder.

         End If

         

          '-- FolderItem functions: Get info about item If file or
folder.

          '-- This gets date modified, type and (If it's a file) size:

         sFI = "ModifyDate - " & Obj.ModifyDate & vbcrlf

          If iItem = 3 Then

             sFI = sFI & "Size - " & Obj.size & vbcrlf

          End If   

         sFI = sFI & "Type - " & Obj.type

           '--Use invokeverb to open the file or folder.

         Obj.InvokeVerb open

         getpath = Obj.Path

      Set Obj = nothing

    End Function

'END OF SCRIPT

 

________________________________

From: thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx] On
Behalf Of Evan Mann
Sent: 11 November 2005 14:04
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Re: Published app with restricted file browsing

 

Did some research, it appears that there is no s milar flag to /root for
iexplore.exe, and the /root command is what I need, as it will let me
direct someone to a particular folder but not go higher then that level,
only down.

 

 

 

 

________________________________

From: thin-bounce@xxxxxxxxxxxxx [mailto:thin-bounce@xxxxxxxxxxxxx] On
Behalf Of BRUTON, Malcolm, FM
Sent: Friday, November 11, 2005 6:00 AM
To: thin@xxxxxxxxxxxxx
Subject: [THIN] Re: Published app with restricted file browsing

We do it this way......We publish C:\WINNT\CTX_explorer.exe /n, /e,
H:\My Documents

 

Where ctx_explorer is a copy of explorer.exe

 

Do a search on MS website for explorer.exe switches.

 

(PS Citrix recommend you use iexpore.exe and there is an articale
somewhere about this)

        -----Original Message-----
        From: thin-bounce@xxxxxxxxxxxxx
[mailto:thin-bounce@xxxxxxxxxxxxx] On Behalf Of Evan Mann
        Sent: 10 November 2005 15:50
        To: thin@xxxxxxxxxxxxx
        Subject: [THIN] Published app with restricted file browsing

        I'd like to have some way to publish explorer, internet
explorer, or some other app so that you are restricted as to where you
browse.  In particular, a users re-directed my docs folder and downward
into their folder.

        Example:  your can access r:\users\jdoe\my documents and any
folder beneath my documents, but they cannot go up a level beyond my
documents. 

         

        I haven't been able to come up with much  yet.  I believe
someone on the list said they were working on a way to do something
similar.  Has anyone seen this done, or have a good suggestion as to
how to do it?



************************************************************************
***********
The Royal Bank of Scotland plc. Registered in Scotland No 90312.
Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. 
Authorised and regulated by the Financial Services Authority 

This e-mail message is confidential and for use by the 
addressee only. If the message is received by anyone other 
than the addressee, please return the message to the sender 
by replying to it and then delete the message from your 
computer. Internet e-mails are not necessarily secure. The 
Royal Bank of Scotland plc does not accept responsibility for 
changes made to this message after it was sent. 

Whilst all reasonable care has been taken to avoid the 
transmission of viruses, it is the responsibility of the recipient to 
ensure that the onward transmission, opening or use of this 
message and any attachments will not adversely affect its 
systems or data. No responsibility is accepted by The Royal 
Bank of Scotland plc in this regard and the recipient should carry 
out such virus and other checks as it considers appropriate. 
Visit our websites at: 
http://www.rbs.co.uk/CBFM 
http://www.rbsmarkets.com 
************************************************************************
********

Other related posts: