List all folders, and subfolders, in a directory

I'm trying to find a way to list all folders, and subfolders, in a directory.  I ran the code below and got a message that says 'Access is Denied'.  There is no way access is denied to that folder. How can I list all folders, and subfolders, in
a directory?
--'C:\Users\Ryan\Desktop\Coding\';
set nocount on
declare @curdir nvarchar(400)
declare @line varchar(400)
declare @command varchar(400)
declare @counter int
If (select count (*) from sys.objects where name='Output') <> 0 DROP TABLE output
If (select count (*) from tempdb.sys.objects where name like '%#Tempoutput%') <> 0 DROP TABLE #Tempoutput  
If (select count (*) from tempdb.sys.objects where name like '%#dirs%') <> 0 DROP TABLE #dirs  
create table #dirs (DIRID int identity(1,1), directory varchar(400))
  Set @command = 'dir "C:\Users\Ryan\Desktop\Coding\Microsoft Access\" /S/O/B/A:D'
 insert into #dirs exec xp_cmdshell @command
  set @counter = (select count(*) from #dirs)
create table #tempoutput (line varchar(400))
create table output (Directory varchar(400), FileSize varchar(400))
    While @Counter <> 0
      Begin
        Declare @filesize int
        set @curdir = (select directory from #dirs where DIRID = @counter)
        set @command = 'dir "' + @curdir +'"'
        insert into #tempoutput
        exec master.dbo.xp_cmdshell @command
           select @line = ltrim(replace(substring(line, charindex(')', line)+1,len(line)), ',', ''))
           from #tempoutput where line like '%File(s)%bytes'
           Set @filesize  = Replace(@line, ' bytes', '')
        Insert into output (directory, Filesize) values (@curdir, @filesize)
        Set @counter = @counter -1
       End
       Delete from output where Directory is null
select * from output
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

Can you tell us how you're executing this code? Is it called from sql agent job or are you executing it by calling code directly?
Did you try creating a proxy for xp_cmdshell and then executing it?
http://www.mssqltips.com/sqlservertip/2143/creating-a-sql-server-proxy-account-to-run-xpcmdshell/
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Closing all folders and subfolders within a window with one command

    In list view, is there a way to close all folders and subfolders within a window with one command, instead of having to close each individually?
    Thanks!

    Thanks, all, for your feedback, but no cigar, yet:
    - opening folders with "option" is possible but problematic
    - none of this solves the question of closing all the folders and subfolders within a window in one shot.
    Any better solution would be appreciated.
    Thanks!

  • How to list all files and directories in another directory

    I need to be able to list all the directories and files in a directory. I need to write a servlet that allows me to create an html page that has a list of files in that directory and also list all the directories. That list of files will be put into an applet tag as a parameter for an applet that I have already written. I am assuming that reading directories/files recursively on a web server will be the same as reading directories/files on a local system, but I don't know how to do that either.

    Hi,
    Here is a method to rotate through a directory and put all the files into a Vector (files).
          * Iterates throught the files in the root file / directory that is passed
          * as a parameter. The files are loaded into a <code>Vector</code> for
          * processing later.
          * @param file the root directory or the file
          *         that you wish to have inspected.
         public void loadFiles(File file) {
              if (file.isDirectory()) {
                   File[] entry= file.listFiles();
                   for (int i= 0; i < entry.length; i++) {
                        if (entry.isFile()) {
                             //Add the file to the list
                             files.add(entry[i]);
                        } else {
                             if (entry[i].isDirectory()) {
                                  //Iterate over the entries again
                                  loadFiles(entry[i]);
              } else {
                   if (file.isFile()) {
                        //Add the file
                        files.add(file);
    See ya
    Michael

  • Does bridge search all folders and subfolders by default?

    Many documents and folders are not being found with Bridge's search feature.  What do I need to do to have Bridge A) find files in specific folders and B) search newly added folders?  Does bridge search every folder on my computer by default or just specific ones?  If the latter, how do I let bridge know which folders it should add to its searches?  THanks.

    Bridge starts the search where you tell it and then moves down the dirctory tree.  So if
    your folder is above the start point it will not be searched.

  • Modifying my script to list all folders and their lastwritetime on remote computers

    Hello,
    I've got the following script that is trying to report on a list of computers (in computerlist.txt) the contents of the C:\Users folder and list in the resulting CSV File the Name of the computer, the Folder Name and the Date it was last changed (sort by
    most recent first).
    $servers = GC C:\Powershell_Scripts\computerlist.txt
    ForEach($server in $servers) {
    If (Test-Connection -comp $server -count 1 -quiet) {
    Get-Childitem ("\\$server\c$\Users") | Where-Object { $_.mode -like 'd*' } | Select-Object $server, Name, LastWriteTime | Export-Csv C:\Apps\Powershell_Scripts\LastLogin\Reports\directoryFile.csv
    I'm part way there but my script is not showing each computer..only the last computer in the list.
    Please assist with making the necessary changes to this script.
    Thank you.

    Thanks for the reply Mike.
    I am running version 3.  I've added the -Append to my script but it doesn't seem to like it.  Here's the error I get:
    Export-Csv : Cannot append CSV content to the following file: C:\Powershell_Scripts\Reports\directoryFile.csv. The appended object does not have a property that corresponds to the following column: ServerABC. To proceed with mismatched
    properties, add the -Force switch and retry.
    Where ServerABC is the name of the first server in computerlist.txt. 
    Here is how I added the -Append:
    $servers = GC C:\Powershell_Scripts\computerlist.txt
    ForEach($server in $servers) {
    If (Test-Connection -comp $server -count 1 -quiet) {
    Get-Childitem ("\\$server\c$\Users") | Where-Object { $_.mode -like 'd*' } | Select-Object $server, Name, LastWriteTime | Export-Csv -Append C:\Apps\Powershell_Scripts\LastLogin\Reports\directoryFile.csv
    The report being written out also isn't in the format I need.
    ServerABC Name LastWriteTime
    User1 5/12/2014 16:11
    ADMINI~1 7/30/2012 13:37
    User2 4/1/2014 18:23
    How do I modify this to show the following output instead:
    Computer Name LastWriteTime
    ServerABC User1 5/12/2014 16:11
    ADMINI~1 7/30/2012 13:37
    User2 4/1/2014 18:23
    ServerDEF User1 6/14/2014 14:12
    ADMINI~1 6/24/2012 15:38
    User2 5/1/2014 20:25
    Thank you.

  • Mail folders And subfolders

    I made An mail account with which synchronize with exchange. In outlook i have made within each archive folder I have many subfolders. On my iPad it shows All folders And subfolders totally.
    How can I fold in the folders and subfolders?
    Thanks already

    AFAIK, you can't collapse email folders in the iPhone's Mail app.

  • Copy only files from folders and subfolders

    I need a help.
    I have issue with too long destination part, so I want to use some script or command, to copy all files (just files) from all folders and subfolders to one destination (one specified folder).
    I don't need folders and subfolders, just files.
    I have this issue on Windows 7 Professional.
    Best regards

    Try this batch file. It will overwrite files with duplicated names.
    @echo off
    set Source=d:\My Documents
    set Dest=d:\My New Folder
    xcopy /y "%Source%" "%Dest%\"
    for /F "delims=" %%a in ('dir /ad /b /s "%Source%"') do xcopy /y "%%a\*.*"  "%Dest%"

  • How can I transfer/copy my entire iPhoto library from one iMac to another iMac whilst keeping all the folders and subfolders intact?

    We recently purchased a new iMac for our office (8 GB memory, 2.7 processor, version 10.9.2) and we need to copy the iPhoto library from our other iMac (version 10.9.4) onto the new one. The photos are essential for our work and there are around 53,000 of them all organised into folders and subfolders and then the photos are manually ordered within the albums.
    We have tried connecting the computers but when we tried to access the iPhoto library on the new iMac it says that iPhoto is locked and we do not have permission to view it. We updated iPhoto on the old iMac as we thought that might be the problem but the message still appears. We've been advised to use an external hard drive but we're worried that will corrupt the organisation of the library. We have also been told not to do it over AirDrop / the Server because of the sheer quantity of photos.
    Any advice on how to safely do this would be much appreciated.

    No idea exactly what you did
    if you followed the instructions
    Simply copy the iPhoto Library from the Pictures Folder on the old Machine to the Pictures Folder on the new Machine.
    Then launch iPhoto. That's it.
    This moves photos, events, albums, books, keywords, slideshows and everything else.
    then you have exactly the same thin on your new system that you had on the old
    If you do something differently - like import the library instead of simply opening it - then it will not work
    did you dimply drag the iPhoto library from the pictures folder of the old machine to the pictures folder of the new machine and then launch iPhoto on the new machine?
    and to help it is important to use word correctly since that is the only communications method we have - in iPhoto folders do not contain photos - you view photos in events and you can organize them using albums (which view photos) and folders (which hold either albums or other folders - folders never have photos in them) so your description of the problem is not at all clear since it uses folders incorretly
    LN

  • Query to get a listing of all folders and joins in EUL

    If anybody has a query that provides a listing of all folders and joins between those folders in a Discoverer EUL, can you please share it.
    Any help would be greatly appreciated.

    Hi
    As Rod commented you won't get an accurate listing going through XREFS. You need to look in the statistics table, EUL5_QPP_STATS where you will find a history of all worksheets that have been executed. Unfortunately the item columns in EUL5_QPP_STATS are encoded so you will need some special SQL to uncode them.
    First of all you will need to have installed the EUL extensions which can be found in the script called EUL5.SQL (located in the Discoverer\Util folder where Admin is installed) when logged in as the owner of the EUL. Theh try running this script, altering the data switch to a suitable date:
    SELECT
    QS.QS_DOC_OWNER    USER_NAME,
    QS.QS_DOC_NAME     WORKBOOK,
    QS.QS_DOC_DETAILS  WORKSHEET,
    TRUNC(QS.QS_CREATED_DATE) EXECUTION_DATE,
    *(LENGTH(TO_CHAR(EUL5_GET_ITEM_NAME(QS.QS_ID)))+1)/9 ITEMS,*
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),1,  6)) ITEM1,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),10, 6)) ITEM2,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),19, 6)) ITEM3,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),28, 6)) ITEM4,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),37, 6)) ITEM5,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),46, 6)) ITEM6,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),55, 6)) ITEM7,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),64, 6)) ITEM8,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),73, 6)) ITEM9,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),82, 6)) ITEM10,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),91, 6)) ITEM11,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),100,6)) ITEM12,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),109,6)) ITEM13,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),118,6)) ITEM14,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),127,6)) ITEM15,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),136,6)) ITEM16,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),145,6)) ITEM17,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),154,6)) ITEM18,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),163,6)) ITEM19,
    EUL5_GET_ITEM(SUBSTR(EUL5_GET_ITEM_NAME(QS.QS_ID),172,6)) ITEM20
    FROM
    EUL5_QPP_STATS QS
    WHERE
    *(LENGTH(TO_CHAR(EUL5_GET_ITEM_NAME(QS.QS_ID)))+1)/9 < 21*
    AND QS.QS_CREATED_DATE > '01-JAN-2009'
    Best wishes
    Michael

  • Mac does not list all folders in a SMB share

    Hi guys, this is a bit of a weird one and I've tried everything I can think of.
    In our house we have a media centre running Windows 7. It has several shares, one of which we'll call folder "X". Folder X opens correctly on the media centre, and any other Windows machine perfectly. Almost every other machine in the house is running OS X 10.6, and one of my housemates today noted that some of the folders inside of folder X were not listed on a Mac. So far we've tested it on 2 Macs and 2 Windows machines, and everytime the Windows machine lists all folders inside of X, where the Mac does not. The weird thing is, it's cutting them out alphabetically, so it's basically from D through to I that are missing, all in all there are 30 (out of 160) folders missing inside of Folder X...here's what I've tried.
    On the Windows 7 machine:
    -Restarted server service
    -Removed Share X and re-added
    -Checked share permissions on folder X
    -Checked permissions on folder X, propagated to all child folders just in case.
    -Restarted machine after every change.
    On the Macs we haven't really tried much as there's not much we can think to change. We've tried Finder, Path Finder (which I'm guessing will be exactly the same), restarting, removing from workgroup and re-adding...I can't think what would cause such a weird problem.
    To make things harder we don't know exactly when it started happening but the OSX machines definitely used to list the folders and it happens on more than one mac. which I guess makes me think it's something on the Windows client. The 30 folders are not using any nonstandard characters, some are only a few letters long.
    Ideas on a postcard!?

    Reporting the same problem.
    1. Have Windows 7 MediaCenter with file sharing set up properly (LM+NTLM Authentication allowed and 128-bit encryption disabled in security policies).
    2. Test folder ("C:\income") and all the subfolders' owner is 'Guest', full access is granted for everyone.
    3. Connecting to MediaCenter from MacBook with Finder by pressing Cmd+K and typing smb://ip-addr/income
    4. Finder connects successfully, but some sub-folders and files are not being listed.
    Workaround:
    5. You can open a not-listed folder directly by pressing Cmd+K and typing smb://ip-addr/income/some-invisible-folder
    6. Voila! You're inside invisible folder.
    In the meantime, i can see all the sub-folders on a Windows XP client machine, so i can make a conclusion that all of these 'invisible' sub-folders are actually accessible by Finder, but in some reason are just not being listed on Mac.

  • Arranging Folders and Subfolders

    We are in the process of re-arranging our content into folders and subfolders, and I have heard concerns that after the users have created their folders and subfolders, that they have no way of controlling the order in which they are displayed. This is rather important to us as they want to make sure the most important folders are listed towards the top fo the list, and being that they will be continuously adding folders, it is currently impossible to meet their needs.
    Is there a way to manualy or otherwise sort folders the same way there is to re-arange items (little blue up-arrow)? Thanks in advance.

    Thanks Product Manager! That has been right under our noses all this time and we didn't even know that functionality was there. You have made our week!!

  • Search into folders and subfolders

    I must realize a procedure ColdFusione that effects the
    search into folders and subfolders
    on the file System that simulates the Windows API, specially
    the function PathMatchSpecW().
    How can I realize it?

    Thanks for the information,
    I must realize an optimistic search of folders and files.
    For example in "C:\App\" I have 3 folders Fp_1, Fp_2, Fp_3.
    Gives the run "C:\App\Fp_*" I must get the list of the 3
    folders.
    I use this code:
    <CFDIRECTORY DIRECTORY="C:\App\Fp_*"
    NAME="MyDir"
    SORT="name ASC">
    <CFTABLE QUERY="MyDir">
    <CFCOL HEADER="NAME:" TEXT="#Name#">
    <CFCOL HEADER="SIZE:" TEXT="#Size#">
    </CFTABLE>
    I have not a record!
    Can you write a correct example code?

  • Copying folders and Subfolders with files using Promises WinJS

    Hi,
    I have app written in WinJS.
    I want to copy a particular folder along with its subfolders and their files. I am so far successful with copying folders. Below is the code for the same.
    app.CopyFolder = function (folder, destFolder) {
    var replace = Windows.Storage.CreationCollisionOption.replaceExisting;
    //console.log("create folder: " + folder.name);
    return destFolder.createFolderAsync(folder.name, replace).then(function (newdest) {
    return app.CopySubFolders(folder, newdest);
    app.CopySubFolders=function(folder, destFolder) {
    return folder.getFoldersAsync().then(function (folderlist) {
    return WinJS.Promise.join(folderlist.map(function (folder) {
    return app.CopyFolder(folder, destFolder);
    Now after I have copied all the folders I need to copy their respective files. The problem is I am stuck,I get the files copied but I want to proceed ahead after all the files are written to their respective folders. Below is the code for the same.
    app.copyAllFiles = function (fileList, destStorFolder) {
    console.log('copyFiles Start...');
    var promises = [];
    var fileCopied = 0;
    var collideOpt = Windows.Storage.CreationCollisionOption.replaceExisting;
    return WinJS.Promise.join(fileList.map(function (file) {
    return app.copySingleFile(file, destStorFolder);
    app.copySingleFile = function (fileObject, destFolder) {
    var promises = [];
    var fileCopied = 0;
    var path = destFolder.path + "\\" + fileObject.folderName;
    var collideOpt = Windows.Storage.CreationCollisionOption.replaceExisting;
    return Windows.Storage.StorageFolder.getFolderFromPathAsync(path).done(function (folderObjectOfLocalFolder) {
    return fileObject.fileObject.copyAsync(folderObjectOfLocalFolder, fileObject.fileName, collideOpt).then(function (fileObject) {
    console.log("copied single file:" + fileObject.name);
    The problem is when i run the folder copy code and apply breakpoint for the success call back of 
    CopySubFolders(source,destination).done(/*my breakpoint*/)
    The folders are created.
    But when I try to breakpoint for my copyAllFiles,the files are created only when i pass the success call back.
    Can anyone tell me what am i doing wrong? How can I proceed ahead only when all the files are written successfully.
    Regards,
    Ninad 

    Hi,
    I tried the above solution but what i want is that the action of copying folders and subfolders along with the files should be done with promises and that promise should return only when all folders,sunfolders and their files have been copied. I want to
    do it in this way because I want to perform certain second action only when all things are copied.
    If I do it the as per the link the function runs in the background and my second action proceed aheads and may cause error if it finds some folder or file missing.
    So I came up with following above code,first copy folders then copy. The copy folder works as expected but the files are getting copied only when the file copying code enters the success call back.
    Can you please shed light on my code where I am going wrong.
    Or is it ok to proceed ahead with the solution you mentioned at the link cause I dont want any runtime crashes.
    Regards,
    Ninad

  • HT204655 Can I create folders and subfolders in the new Photos on my mac?

    I've just started using the new Photos app in the latest Yosemite update on my Macbook Pro.
    Until recently I was using Aperture to sort all my photos into folders and subfolders - I think they were called "events" or "projects" in Aperture. 
    In Aperture, I was creating folders like "1993", "1994", "1995" or "Best of My Family".
    Then I had subfolders within those folders - things like a "Christmas 1995", and perhaps some subfolders within that like "Christmas 1995 at Home", "Christmas 1995 at Parents" as well as things like a "favorite 1995 pics".
    And sometime non-date related folders - things like "Children as Babies" subfolder or "Parents on Vacations" subfolder within the "Family" folder.  
    These folders and subfolders seem to have been carried through to this new Photos app as "iPhotos Events".
    But I dont seem to be able to continue sorting - like creating new subfolders within folders.   For example, in Photos I don't seem to be able to create an album within in an album.
    Am I missing a trick here?
    Is Photos unable to do this?
    Or, is the community please able to suggest another alternative solution - like, would using the Pictures folder in Finder be better, perhaps in conjunction with DropBox instead of iCloud?
    Or another photo organizing app that is able to sort folders and subfolders?
    Thank you for your help in advance!

    One way to create folders, subfolders, albums, is to make sure you have your Sidebar showing (menu - view > sidebar) and then use "Control + mouse click" on a folder you want to create a subfolder or album in to bring up the contextual menu.   You can also do these things in the upper right of the Photos window using the + icon but that always seemed to put those items in the top level of the sidebar so I would have to drag and drop them to the folder where I wanted them to go.
    Lori

  • How to list all the Fields for an Active Directory Object

    How do I list all the fields that an Active Directory object contains? I know the most common ones, but would like to enumerate through all the fields and obtain the type of fields and their values...

    Here is my complete code - I only put snippets so that the post was not too huge...
    Option Explicit
    Const ADS_SCOPE_SUBTREE = 2
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    Dim adoCommand, adoConnection, adoRecordSet
    Dim dtmDate, dtmValue
    Dim j
    Dim lngBias, lngBiasKey, lngHigh, lngLow, lngValue
    Dim objADObject, objClass, objDate, objFile, objFSO, objRootDSE, objShell
    Dim pathToScript
    Dim strAdsPath, strConfig, strDNSDomain, strHex, strItem, strProperty, strValue
    Dim strFilter, strQuery
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("Wscript.Shell")
    pathToScript = objShell.CurrentDirectory
    Set objFile = objFSO.CreateTextFile(pathToScript & "\TestAD.csv")
    ' Determine Time Zone bias in local registry.
    ' This bias changes with Daylight Savings Time.
    lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
    If (UCase(TypeName(lngBiasKey)) = "LONG") Then
    lngBias = lngBiasKey
    ElseIf (UCase(TypeName(lngBiasKey)) = "VARIANT()") Then
    lngBias = 0
    For j = 0 To UBound(lngBiasKey)
    lngBias = lngBias + (lngBiasKey(j) * 256^j)
    Next
    End If
    ' Determine configuration context and DNS domain from RootDSE object.
    Set objRootDSE = GetObject("LDAP://RootDSE")
    strConfig = objRootDSE.Get("configurationNamingContext")
    strDNSDomain = objRootDSE.Get("defaultNamingContext")
    Set adoCommand = CreateObject("ADODB.Command")
    Set adoConnection = CreateObject("ADODB.Connection")
    adoConnection.Provider = "ADsDSOObject"
    adoConnection.Open "Active Directory Provider"
    adoCommand.ActiveConnection = adoConnection
    adoCommand.CommandText = "SELECT * FROM 'LDAP://" & strDNSDomain & "'WHERE objectClass=user'"
    adoCommand.Properties("Page Size") = 1000
    adoCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
    Set adoRecordSet = adoCommand.Execute
    Set adoRecordSet = adoCommand.Execute
    adoRecordSet.MoveFirst
    Do Until adoRecordSet.EOF
    strAdsPath = adoRecordSet.Fields("ADsPath").Value
    ' Bind to Active Directory object specified.
    Set objADObject = GetObject(strAdsPath)
    Set objClass = GetObject(objADObject.Schema)
    ' Write which object is grabbed from AD
    objFile.Write(Replace(strAdsPath, ",", ";;;"))
    ' Enumerate mandatory object properties.
    For Each strProperty In objClass.MandatoryProperties
    On Error Resume Next
    strValue = objADObject.Get(strProperty)
    If (Err.Number = 0) Then
    On Error GoTo 0
    If (TypeName(strValue) = "String") Or (TypeName(strValue) = "Long") Or (TypeName(strValue) = "Date") Then
    objFile.Write("," & strProperty & "|||" & Replace(CStr(strValue), ",", ";;;"))
    ElseIf (TypeName(strValue) = "Byte()") Then
    strHex = OctetToHexStr(strValue)
    objFile.Write("," & strProperty & "|||" & CStr(strHex))
    ElseIf (TypeName(strValue) = "Variant()") Then
    For Each strItem In strValue
    On Error Resume Next
    objFile.Write("," & strProperty & "|||" & Replace(CStr(strItem), ",", ";;;"))
    If (Err.Number <> 0) Then
    On Error GoTo 0
    objFile.Write("," & strProperty & "|||Value cannot be displayed")
    End If
    On Error GoTo 0
    Next
    ElseIf (TypeName(strValue) = "Boolean") Then
    objFile.Write("," & strProperty & "|||" & CBool(strValue))
    Else
    objFile.Write("," & strProperty & "|||Type:" & TypeName(strValue))
    End If
    Else
    Err.Clear
    sColl = objADObject.GetEx(strProperty)
    If (Err.Number = 0) Then
    For Each strItem In sColl
    objFile.Write("," & strProperty & "|||" & CStr(strItem))
    If (Err.Number <> 0) Then
    objFile.Write("," & strProperty & "|||Value cannot be displayed")
    End If
    Next
    On Error GoTo 0
    Else
    Err.Clear
    Set objDate = objADObject.Get(strProperty)
    If (Err.Number = 0) Then
    lngHigh = objDate.HighPart
    If (Err.Number = 0) Then
    lngLow = objDate.LowPart
    If (lngLow < 0) Then
    lngHigh = lngHigh + 1
    End If
    lngValue = (lngHigh * (2 ^ 32)) + lngLow
    If (lngValue > 120000000000000000) Then
    dtmValue = #1/1/1601# + (lngValue / 600000000 - lngBias) / 1440
    On Error Resume Next
    dtmDate = CDate(dtmValue)
    If (Err.Number <> 0) Then
    objFile.Write("," & strProperty & "|||<Never>")
    Else
    objFile.Write("," & strProperty & "|||" & CStr(dtmDate))
    End If
    Else
    objFile.Write("," & strProperty & "|||" & FormatNumber(lngValue, 0))
    End If
    Else
    objFile.Write("," & strProperty & "|||Value cannot be displayed")
    End If
    Else
    On Error GoTo 0
    objFile.Write("," & strProperty)
    End If
    On Error GoTo 0
    End If
    End If
    Next
    ' Enumerate optional object properties.
    For Each strProperty In objClass.OptionalProperties
    On Error Resume Next
    strValue = objADObject.Get(strProperty)
    If (Err.Number = 0) Then
    On Error GoTo 0
    If (TypeName(strValue) = "String") Then
    objFile.Write("," & strProperty & "|||" & Replace(CStr(strValue), ",", ";;;"))
    ElseIf (TypeName(strValue) = "Long") Then
    objFile.Write("," & strProperty & "|||" & Replace(CStr(strValue), ",", ";;;"))
    ElseIf (TypeName(strValue) = "Date") Then
    objFile.Write("," & strProperty & "|||" & Replace(CStr(strValue), ",", ";;;"))
    ElseIf (TypeName(strValue) = "Byte()") Then
    strHex = OctetToHexStr(strValue)
    objFile.Write("," & strProperty & "|||" & CStr(strHex))
    ElseIf (TypeName(strValue) = "Variant()") Then
    For Each strItem In strValue
    On Error Resume Next
    objFile.Write("," & strProperty & "|||" & Replace(CStr(strItem), ",", ";;;"))
    If (Err.Number <> 0) Then
    On Error GoTo 0
    objFile.Write("," & strProperty & "|||Value cannot be displayed")
    End If
    On Error GoTo 0
    Next
    ElseIf (TypeName(strValue) = "Boolean") Then
    objFile.Write("," & strProperty & "|||" & CBool(strValue))
    Else
    objFile.Write("," & strProperty & "|||Type:" & TypeName(strValue))
    End If
    Else
    Err.Clear
    sColl = objADObject.GetEx(strProperty)
    If (Err.Number = 0) Then
    For Each strItem In sColl
    objFile.Write("," & strProperty & "|||" & CStr(strItem))
    If (Err.Number <> 0) Then
    objFile.Write("," & strProperty & "|||Value cannot be displayed")
    End If
    Next
    On Error GoTo 0
    Else
    Err.Clear
    Set objDate = objADObject.Get(strProperty)
    If (Err.Number = 0) Then
    lngHigh = objDate.HighPart
    If (Err.Number = 0) Then
    lngLow = objDate.LowPart
    If (lngLow < 0) Then
    lngHigh = lngHigh + 1
    End If
    lngValue = (lngHigh * (2 ^ 32)) + lngLow
    If (lngValue > 120000000000000000) Then
    dtmValue = #1/1/1601# + (lngValue / 600000000 - lngBias) / 1440
    On Error Resume Next
    dtmDate = CDate(dtmValue)
    If (Err.Number <> 0) Then
    objFile.Write("," & strProperty & "|||<Never>")
    Else
    objFile.Write("," & strProperty & "|||" & CStr(dtmDate))
    End If
    Else
    objFile.Write("," & strProperty & "|||" & lngValue)
    End If
    Else
    objFile.Write("," & strProperty & "|||Value cannot be displayed")
    End If
    Else
    On Error GoTo 0
    objFile.Write("," & strProperty & "||| ")
    End If
    On Error GoTo 0
    End If
    End If
    Next
    objFile.WriteLine("")
    adoRecordSet.MoveNext
    Loop
    objFile.Close
    ' Function to convert OctetString (Byte Array) to a hex string.
    Function OctetToHexStr(arrbytOctet)
    Dim k
    OctetToHexStr = ""
    For k = 1 To Lenb(arrbytOctet)
    OctetToHexStr = OctetToHexStr _
    & Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
    Next
    End Function
    I have been able to obtain all the Computer, Contact, Group and OU objects without issue with this code...

Maybe you are looking for

  • TeSt MeSsAgE- whYIs It TyPiNg LiKe ThIs?The scribed in my previous pOsT

    i have applied update 1526 and restarted.  the same exact problem exists as d (rest of this sentence bounced back to the subject line) this appears to be a problem with creating new posts from this webpage, from the playbook. this is only happening o

  • Request for sample code, Validating XML Schema

    Does anyone have some sample code to validate an XML Schema with the Oracle parser? Also, the classgen code seems to have more XML Schema classes in it. There is an xschema.jar full of XML Schema related code. Would it be possible to use this code? I

  • How do I set up printer to air print from the iPad

    how do I set up my hp deskjet 3054 to air print?

  • How do I recover photos that I deleted

    I just returned from a trip, took hundreds of pictures with my iPhone, downloaded them onto my iMac, deleted them from the iPhone, then found that many I had taken did not appear on the iMac. Help!

  • Reporting reqirement

    Hi all, can any one give me please the transaction code or path for the following report like: Printing all Vouchers: Sales Invoice, Purchase order, Bank Check Paymennnt. Debit Note, Credit Note,Sales Order, Bank payment and receipt, cash paymennt an