4 Replies Latest reply on Nov 19, 2008 12:45 PM by svillardi

    Query for folder existance


      I have a need to query for the existance of a folder (i.e., path to folder exists) regardless of any content in the folder.  I have been able to use "Computer.Software.Package.Path LIKE c:\folder1\folder2" where folder2 had installed software successfully but have no luck finding how to query to see if a folder exists.

        • 1. Re: Query for folder existance
          ahe Expert



          I don't know which LANDesk version you use, but you can use "Not Exists" in your query for the entry:



          Value: your path





          1 of 1 people found this helpful
          • 2. Re: Query for folder existance



            I'm trying to find a profile for a specific user but cannot.


            I have tried "Computer"."Software"."Package"."Path" = "C:\Documents And Settings\username" but it doesn't give me anything.


            Please assist.

            • 3. Re: Query for folder existance

              I dont believe this is available out of the box.. A few different ways to collect directory information exist, You may want to vb script something to either parse the docs & settings folder names to an array or text and 'if exists' your value, then write it to a reg key for that PC, then include that in your ldappl3.Template.


              If you use vb.net, the code below does something similar (finds a file), but i needed to write to a intermediate database, you're welcome to edit and compile if it helps.


              Imports System.IO
              Imports System.Data
              Imports System.Data.Sql
              Imports System.Data.SqlClient

              Public Class Form1

                  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                      Dim dri As IO.DirectoryInfo
                      Dim di As New IO.DirectoryInfo("c:\")

                      Dim fileinfo As New IO.FileInfo("csxview.ma")
                      Dim diArr As IO.DirectoryInfo() = di.GetDirectories()

                      Dim fil As IO.FileInfo

                      Dim FileArr As IO.FileInfo() = di.GetFiles("*.ma", IO.SearchOption.TopDirectoryOnly)

                      For Each dri In diArr
                          If dri.FullName = "c:\win32app" Then
                              Dim dir As String = ("c:\" & dri.FullName)
                              'Console.WriteLine("Found Directory " & dri.FullName)
                              ListBox1.Items.Add(dri.FullName & " found")


                              Dim dirw As New DirectoryInfo(dri.FullName)
                              Dim fiArr As FileInfo() = dirw.GetFiles("csxview.ma", SearchOption.AllDirectories)
                              Dim fri As FileInfo
                              For Each fri In fiArr
                                  If fri.Name.ToLower = "csxview.ma" Then

                                          Dim myConnection As SqlConnection
                                          Dim myCommand As SqlCommand
                                          Dim ra As Integer

                                          myConnection = New SqlConnection("server=yourserver;database=TACTUtilities;User ID=youruser;Password=yourpass")

                                          myCommand = New SqlCommand("INSERT INTO RPIcsxview_info (ComputerName, Path ) VALUES('" & My.Computer.Name & "','" & (fri.FullName) & "')", myConnection)
                                          ra = myCommand.ExecuteNonQuery()
                                      End Try

                                  End If
                              Next fri

                          End If

                      Next dri


                  End Sub
              End Class

              • 4. Re: Query for folder existance

                Thank you.  Way above my head, but thanks anyway.