KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Display Owner of Files & Folders

 
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive
View previous topic :: View next topic  
Author Message
richardrfarthing
KiXforms Supporter
KiXforms Supporter


Joined: 09 Apr 2003
Posts: 71
Location: London, ENGLAND

PostPosted: Mon Sep 01, 2003 12:30 pm    Post subject: Display Owner of Files & Folders Reply with quote

A explorer like application to list the owner of each file and folder.

Rich



Code:


;   *********************************************************************************
;   * Script Name:      Display Owner of Files & Folders                    *
;   * Creator:      Richard Farthing - Queen Elizabeth Hospital NHS Trust      *
;   * Date:         1/09/03                                 *   
;   * Requirments      FileOwner Function, KiXforms v2.3.0 Beta 3,            *
;   *            KiXtart 4.22 Beta 1                           *
;   *********************************************************************************


Break On ; Break On to allow user to break out

;**********************************************************************************************************
;Checking that KiXtart Forms DLL is Registered
If NOT ReadValue("HKEY_CLASSES_ROOT\CLSID\{78F2E57A-21C9-467D-B20B-6836E9A36272}\InprocServer32", "ThreadingModel") = "Both"
   MessageBox("KiXtart Forms Register DLL Failed, Please contact the IMT Helpdesk on x6049",
   "Displays Owner of Files & Folders - KiXtart Forms DLL Register Failed", 0)
GoTo End
EndIf

;**********************************************************************************************************
$KiX = "D:\KiX" ; Set the KiX verable
Call $Kix+'\Functions\FileOwner().Kix' ; Calling the FileOwner() Function

;**********************************************************************************************************
;Type in the Drive Letters of the Shared Drive and the IMS Drive.

$FirstDrive = "C:\"
$SecondDrive = "D:\" ;Leave as "" if you do not want a second drive.

;**********************************************************************************************************
;Create Object to KiXtart Form
$FORM = CreateObject("Kixtart.Form")

;**********************************************************************************************************
;Main Form

$FORM.Caption                        = "Displays Owner of Files & Folders"
$FORM.ScaleHeight                     = 240
$FORM.ScaleWidth                     = 405
$FORM.FontSize                        = 8
$FORM.Center   

;**********************************************************************************************************
;Current Directory Label

$ListCurrentDir                     = $FORM.Label
$ListCurrentDir.Left                  = 5
$ListCurrentDir.Top                     = 30
$ListCurrentDir.Width                  = 380
$ListCurrentDir.Height                  = 20
$ListCurrentDir.FontSize                  = 8
$ListCurrentDir.FONTNAME                = "Arial"
$ListCurrentDir.Enabled                  = 0

$lblCurrentDir                        = $FORM.Label("Current Folder: ")
$lblCurrentDir.Left                     = 5
$lblCurrentDir.Top                     = 15
$lblCurrentDir.Width                  = 120
$lblCurrentDir.Height                  = 20
$lblCurrentDir.FontSize                  = 8
$lblCurrentDir.FONTNAME                   = "Arial"
$lblCurrentDir.Enabled                  = 0

;**********************************************************************************************************
;ListView for OwnerList

$GetOwnerListBox                     = $FORM.Listview
$GetOwnerListBox.Left                  = 5
$GetOwnerListBox.Top                  = 55
$GetOwnerListBox.Width                  = 395
$GetOwnerListBox.Height                  = 160
$GetOwnerListBox.FontSize               = 8
$GetOwnerListBox.FONTNAME                = "Arial"
$GetOwnerListBox.View                   = 1
$GetOwnerListBox.SmallImageList             = $Form.SmallImageList
$GetOwnerListBox.OnDoubleClick            = "ListView_DoubleClick()"
$=$GetOwnerListBox.Columns.Add("Name",250)
$=$GetOwnerListBox.Columns.Add("Owner",125)
$FolderRoot = $FirstDrive

;**********************************************************************************************************
;Command Button for select Drive

If $SecondDrive
   $SelectDrive                           = $FORM.CommandButton
   $SelectDrive.Left                        = 278
   $SelectDrive.Top                        = 7
   $SelectDrive.Width                        = 115
   $SelectDrive.Height                        = 20
   $SelectDrive.FontSize                     = 8
   $SelectDrive.FONTNAME                      = "Arial"
   $SelectDrive.Text                        = "Click to Browse "+$SecondDrive
   $SelectDrive.OnClick                     = "SelectDrive_Click()"
EndIf

;**********************************************************************************************************
;ProgressBar for DirList

$ProgressBar                          = $FORM.ProgressBar()
$ProgressBar.Width                     = 300
$ProgressBar.Height                    = 15
$ProgressBar.Left                      = 50
$ProgressBar.Top                       = 220
$ProgressBar.Style                     = 2
$ProgressBar.Minimum                   = 0
$ProgressBar.Enabled                   = 0

;**********************************************************************************************************
;Objects within Main Form

$FORM.Show ; Show Form

ListView() ; Call ListView Function

While $FORM.Visible
 $=Execute($FORM.DoEvents)
Loop
:End
Exit 1

;***********************************************************************************************************
;Call Functions & UDF's ****
;***********************************************************************************************************


;***********************************************************************************************************
;ListView Function

Function ListView()

Enabled(0) ; Call Enabled Function
$ListCurrentDir.Text = $FolderRoot ; Set Current Directory Label

$FSO = CreateObject("Scripting.FileSystemObject").GetFolder($FolderRoot)
$ProgressBar.Maximum = $FSO.SubFolders.Count + $FSO.Files.Count ; Set the maximum value of the ProgressBar to count of the Files and Folders Array
$=$GetOwnerListBox.Items.Add("..",47) ; Create Item for ".."         

$x = 1
;Folder Array
For Each $FolderListArray In $FSO.SubFolders
   $ProgressBar.Value = $x ; Set Value of ProgressBar to $x
   $Owner = Split(FileOwner($FolderListArray),"\") ;Split Object into an Array using "\"
   $=$GetOwnerListBox.Items.Add($FolderListArray.Name+"\",1) ;Add FolderName Item into Listview
   $GetOwnerListBox.Items($x).SubItems(1).Text = $Owner[Ubound($Owner)] ; Add Owner Item into ListView
   $x = $x + 1   
Next

;File Array
For Each $FileListArray In $FSO.Files
   $ProgressBar.Value = $x
   $Owner = Split(FileOwner($FileListArray),"\")
   $=$GetOwnerListBox.Items.Add($FileListArray.Name,0)
   $GetOwnerListBox.Items($x).SubItems(1).Text = $Owner[Ubound($Owner)]
   $x = $x + 1   
Next

Enabled(1) ; Call the Enabled Function

EndFunction

;***********************************************************************************************************
;ListView Double Click Function

Function ListView_DoubleClick()
 
For Each $Item In $GetOwnerListBox.SelectedItems
   $ItemName = $Item.Text
   If $ItemName = ".." ; If ItemName = ".."
      If NOT $FolderRoot = SubStr($FolderRoot,1,2)+'\' ; If $FolderRoot does NOT Contain the 1st 2 charcters of FolderRoot
         $FolderRootSplit = Split($FolderRoot,"\") ; Splits the FolderRoot into an Array on "\" charcter    
         ReDim PRESERVE $FolderRootSplit[Ubound($FolderRootSplit) -2] ; ReDim the FolderRootSplit Array and cut off the last 2 segments of the array but keep the data
         $FolderRoot = Join($FolderRootSplit,"\")+'\' ; Re join the array and use "\" as the joining character
         $GetOwnerListBox.Items.Clear ; Clear the ListView of all Items
         ListView() ; Call the ListView Function
      EndIf
   Else
      If NOT InStr($ItemName,"\") = 0 ; If "\" is NOT in Selected ItemName
         $FolderRoot = $FolderRoot+"$ItemName" ; Set FolderRoot
         $GetOwnerListBox.Items.Clear ; Clear the ListView of all Items
         ListView() ; Call the ListView Function
      EndIf
   EndIf
Next   

EndFunction

;***********************************************************************************************************
;Set the FolderRoot Verable

Function SelectDrive_Click()

If SubStr($FolderRoot,1,3) = $FirstDrive
   $FolderRoot = $SecondDrive
   $SelectDrive.Text = "Click to Browse "+$FirstDrive
Else
   $FolderRoot = $FirstDrive
   $SelectDrive.Text = "Click to Browse "+$SecondDrive
EndIf

$GetOwnerListBox.Items.Clear
ListView()

EndFunction

;***********************************************************************************************************
; Set the Enabled Function

Function Enabled($Option)
   $ProgressBar.Value = 0
   $GetOwnerListBox.Enabled = $Option

If $SelectDrive.Enabled = 0 OR $SelectDrive.Enabled = 1
    $SelectDrive.Enabled = $Option   
EndIf

EndFunction

;***********************************************************************************************************
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
sptomey
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 18 Mar 2003
Posts: 158

PostPosted: Mon Sep 01, 2003 7:34 pm    Post subject: Reply with quote

Hello Richard...May I make a suggestion. I'm no kix expert by any means...But the dll checking portion failed on my pc. I would suggest changing it to read the sid from the registry before checking it, like so...

Code:
;**********************************************************************************************************
;Checking that KiXtart Forms DLL is Registered
$sid = ReadValue("HKEY_CLASSES_ROOT\Kixtart.Form\CLSID", "")
If NOT ReadValue("HKEY_CLASSES_ROOT\CLSID\$sid\InprocServer32", "ThreadingModel") = "Both"
   MessageBox("KiXtart Forms Register DLL Failed, Please contact the IMT Helpdesk on x6049",
   "Displays Owner of Files & Folders - KiXtart Forms DLL Register Failed", 0)
GoTo End
EndIf

_________________
-Shane
Back to top
View user's profile Send private message MSN Messenger
richardrfarthing
KiXforms Supporter
KiXforms Supporter


Joined: 09 Apr 2003
Posts: 71
Location: London, ENGLAND

PostPosted: Thu Sep 04, 2003 8:16 pm    Post subject: Reply with quote

Spot on, TY
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Thu Sep 11, 2003 9:35 pm    Post subject: Reply with quote

What's up with that GOTO END. You should replace that with EXIT 1 and NEVER use GOTO ever again Wink
_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
adamix
KiXforms Novice
KiXforms Novice


Joined: 24 Aug 2005
Posts: 1

PostPosted: Wed Aug 24, 2005 11:17 am    Post subject: Display Owner of Files & Folders Reply with quote

hi

if I run your scrip, then I get following messege.Can you help me?


ERROR : invalid method/function call: missing comma!
Script: C:\displayOwner.kix
Line : 136

regards
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Wed Aug 24, 2005 1:20 pm    Post subject: Reply with quote

Hey,

that's because Richard didn't include the FileOwner() function but trusts in us having it ready on ... errr ... D:\KiX\Functions\ Confused

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group