Re: What am I missing?

From: Jack Handy (jehandy2_at_sbcglobal.net)
Date: 02/10/05


Date: Thu, 10 Feb 2005 07:22:31 -0500

I did not include the entire script because I did not think I needed to. As
I mentioned, the yesterday variable returns the correct value. The query
works without the extra condition so I already know the rest of the code is
sound. The creationDate is a property of the file object as is Path so it
doesn't need to be declared.

I was asking for help not snotty criticism. Perhaps someone else who acts
in the spirit of these forums by giving helpful advice can take a look at
this for me.

J

"Gerry Hickman" <gerry666uk@yahoo.co.uk> wrote in message
news:OXAQp2vDFHA.2220@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> This is a classic example of why NOT to use VBScript. Utterly horrible!
> The script is not even complete. Where is the variable "yesterday"
> declared, and what's with that 'on error resume next' nonsense? Where is
> the Option Explicit statement? Are we supposed to guess the string
> contained by 'strDirs'. You don't specify a drive letter so this would be
> very inefficient use of CIM_DataFile and esepcaially with the '*'
> operator.
>
> It's a wild guess, but could it be you are trying to perform VBscript's
> Left() function on an undeclared variable called creationDate ?
>
> The actual value of that variable has not been set yet - it's part of the
> query string...
>
> Jack Handy wrote:
>
>> I am writing a script that checks for new files created the previous day.
>> The query returns results when I run everything before the AND. The
>> second condition never seems to get met. I know that files are there
>> that should meet this condition. I also know that the yesterday variable
>> gives me the expected output (i.e. 20050208) which appears to match the
>> "Left(creationDate,8)" output. I must be doing something wrong here
>> although I can't see it. Please take a look .
>>
>> Thanks,
>>
>> Jack
>> __________________________________________________________
>> Set objFileRead = objFSO.OpenTextFile("c:\wolverine\dirs2.txt", 1)
>> Do Until objFileRead.AtEndOfStream
>> strDirs = objFileRead.ReadLine
>> Set objWMIService =
>> GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &
>> "\root\cimv2")
>> Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where
>> Path = '" & strDirs & "\\' AND " & left(creationDate,8) & " = '" &
>> yesterday & "'")
>> on error resume next
>>
>> For Each objFile in colFiles
>> Wscript.Echo objFIle.Name
>>
>> next
>> loop
>> _____________________________________________
>
>
> --
> Gerry Hickman (London UK)



Relevant Pages

  • Re: rename files in directory
    ... When I run your script I get an error: " Microsoft VBScript runtime error: ... contain a " - " string. ... as part of the query. ... if the target folder has files with names in a format other ...
    (microsoft.public.scripting.vbscript)
  • Re: rename files in directory
    ... When I run your script I get an error: " Microsoft VBScript runtime error: ... contain a " - " string. ... as part of the query. ...
    (microsoft.public.scripting.vbscript)
  • Re: What am I missing?
    ... Are we supposed to guess the string ... contained by 'strDirs'. ... Jack Handy wrote: ... > The query returns results when I run everything before the AND. ...
    (microsoft.public.win32.programmer.wmi)
  • Re: HELP! Need AD Query for Last login
    ... query the DCs in the USA domain, how would I modify the script? ... I'm new to VB script and making this simple modification is beyond me at ... >> ' Because the lastLogon attribute is not replicated, ... Then, for each Domain Controller, ADO is used to search the ...
    (microsoft.public.scripting.vbscript)
  • Re: LDAP query information
    ... a "Dim" statement. ... script is run. ... Microsoft MVP Scripting and ADSI ... Can you please provide me info on what to do with the below query? ...
    (microsoft.public.windows.server.scripting)