I have the following script running (snippet from full script) on a
Windows XP box with no errors. When I move the script to a Windows
2000 box (production) I receive an error 80041017 on line with For,
character 1. All I've found online is that some of the winmgmt objects
are named differently in Win2K but I cant seem to find mine as a
problem. Does anyone see my problem?

sSomefolder = filepath
'sPathSpec = Replace(Mid(Dir, 3) & "\", "\", "\\")
sComputer = "." ' local machine
'Queries the sSomefolder to find any files like the name in ivrpins.
'This is necessary since the last characters before the extension are
different
Set qWMISrv = GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
Set aFiles = qWMISrv.ExecQuery("Select * from CIM_Datafile Where "_
& "Drive = 'C:' AND Path = '" & Dir1 & "' AND FileName Like '" _
& stamp_file & sqldate & "%'", , 48)

For Each File In aFiles

msgbox file.FileName

Re: Error 80041017 Looping through Array on Win 2000 by Richard

Richard
Fri Mar 14 08:46:53 CDT 2008


<requeth@gmail.com> wrote in message
news:0ca7c656-331f-47d0-8bed-db672d0bae1d@d62g2000hsf.googlegroups.com...
>I have the following script running (snippet from full script) on a
> Windows XP box with no errors. When I move the script to a Windows
> 2000 box (production) I receive an error 80041017 on line with For,
> character 1. All I've found online is that some of the winmgmt objects
> are named differently in Win2K but I cant seem to find mine as a
> problem. Does anyone see my problem?
>
> sSomefolder = filepath
> 'sPathSpec = Replace(Mid(Dir, 3) & "\", "\", "\\")
> sComputer = "." ' local machine
> 'Queries the sSomefolder to find any files like the name in ivrpins.
> 'This is necessary since the last characters before the extension are
> different
> Set qWMISrv = GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
> Set aFiles = qWMISrv.ExecQuery("Select * from CIM_Datafile Where "_
> & "Drive = 'C:' AND Path = '" & Dir1 & "' AND FileName Like '" _
> & stamp_file & sqldate & "%'", , 48)
>
> For Each File In aFiles
>
> msgbox file.FileName

The error means the query was invalid. Notice that Dir1, stamp_file, and
sqldate have no values, and sSomefilder and filepath are not used. Also, the
path (value of Dir1) should be similar to "\\Scripts\\MyFolder\\". Also, the
FileName property does not include the extension.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--



Re: Error 80041017 Looping through Array on Win 2000 by requeth

requeth
Fri Mar 14 08:53:55 CDT 2008

On Mar 14, 8:46=A0am, "Richard Mueller [MVP]" <rlmueller-
nos...@ameritech.nospam.net> wrote:
> <requ...@gmail.com> wrote in message
>
> news:0ca7c656-331f-47d0-8bed-db672d0bae1d@d62g2000hsf.googlegroups.com...
>
>
>
>
>
> >I have the following script running (snippet from full script) on a
> > Windows XP box with no errors. When I move the script to a Windows
> > 2000 box (production) I receive an error 80041017 on line with For,
> > character 1. All I've found online is that some of the winmgmt objects
> > are named differently in Win2K but I cant seem to find mine as a
> > problem. Does anyone see my problem?
>
> > sSomefolder =3D filepath
> > 'sPathSpec =3D Replace(Mid(Dir, 3) & "\", "\", "\\")
> > sComputer =3D "." ' local machine
> > 'Queries the sSomefolder to find any files like the name in ivrpins.
> > 'This is necessary since the last characters before the extension are
> > different
> > Set qWMISrv =3D GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
> > Set aFiles =3D qWMISrv.ExecQuery("Select * from CIM_Datafile Where "_
> > & "Drive =3D 'C:' AND Path =3D '" & Dir1 & "' AND FileName Like '" _
> > & stamp_file & sqldate & "%'", , 48)
>
> > For Each File In aFiles
>
> > msgbox file.FileName
>
> The error means the query was invalid. Notice that Dir1, stamp_file, and
> sqldate have no values, and sSomefilder and filepath are not used. Also, t=
he
> path (value of Dir1) should be similar to "\\Scripts\\MyFolder\\". Also, t=
he
> FileName property does not include the extension.
>
> --
> Richard Mueller
> Microsoft MVP Scripting and ADSI
> Hilltop Lab -http://www.rlmueller.net
> --- Hide quoted text -
>
> - Show quoted text -


This is only a piece of my code, all values are filled in and work
properly on a Win XP Pro machine. It's when I move this to a 2000
Server that the script breaks.

Re: Error 80041017 Looping through Array on Win 2000 by requeth

requeth
Fri Mar 14 10:30:09 CDT 2008

On Mar 14, 8:53=A0am, "requ...@gmail.com" <requ...@gmail.com> wrote:
> On Mar 14, 8:46=A0am, "Richard Mueller [MVP]" <rlmueller-
>
>
>
>
>
> nos...@ameritech.nospam.net> wrote:
> > <requ...@gmail.com> wrote in message
>
> >news:0ca7c656-331f-47d0-8bed-db672d0bae1d@d62g2000hsf.googlegroups.com...=

>
> > >I have the following script running (snippet from full script) on a
> > > Windows XP box with no errors. When I move the script to a Windows
> > > 2000 box (production) I receive an error 80041017 on line with For,
> > > character 1. All I've found online is that some of the winmgmt objects=

> > > are named differently in Win2K but I cant seem to find mine as a
> > > problem. Does anyone see my problem?
>
> > > sSomefolder =3D filepath
> > > 'sPathSpec =3D Replace(Mid(Dir, 3) & "\", "\", "\\")
> > > sComputer =3D "." ' local machine
> > > 'Queries the sSomefolder to find any files like the name in ivrpins.
> > > 'This is necessary since the last characters before the extension are
> > > different
> > > Set qWMISrv =3D GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
> > > Set aFiles =3D qWMISrv.ExecQuery("Select * from CIM_Datafile Where "_
> > > & "Drive =3D 'C:' AND Path =3D '" & Dir1 & "' AND FileName Like '" _
> > > & stamp_file & sqldate & "%'", , 48)
>
> > > For Each File In aFiles
>
> > > msgbox file.FileName
>
> > The error means the query was invalid. Notice that Dir1, stamp_file, and=

> > sqldate have no values, and sSomefilder and filepath are not used. Also,=
the
> > path (value of Dir1) should be similar to "\\Scripts\\MyFolder\\". Also,=
the
> > FileName property does not include the extension.
>
> > --
> > Richard Mueller
> > Microsoft MVP Scripting and ADSI
> > Hilltop Lab -http://www.rlmueller.net
> > --- Hide quoted text -
>
> > - Show quoted text -
>
> This is only a piece of my code, all values are filled in and work
> properly on a Win XP Pro machine. It's when I move this to a 2000
> Server that the script breaks.- Hide quoted text -
>
> - Show quoted text -

Here's a new example that's a little more complete:

strComputer =3D "."
Set objSWbemServices =3D _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Dir1 =3D "\\TransferTemp\\"
stamp_file =3D "ABC_FILES"
Set colServices =3D _
objSWbemServices.ExecQuery("Select * from CIM_Datafile Where "_
& "Drive =3D 'C:' AND Path =3D '" & Dir1 & "' AND FileName Like '" _
& stamp_file & "%'", , 48)

For Each objService In colServices
msgbox objService
Next

The directory C:\TransferTemp has 3 files named:

ABC_FILES_20080306.TXT
ABC_FILES_20080310.TXT
ABC_FILES_20080312.TXT

I want the script to pick these up and put them into an array so I can
parse them out, but when I take this code out and put it into a
seperate file, I receive an error on line 12 0x80041017 is the error
code. Again this works on my Win XP machine and the directory
structure/files are identicle.

When I put the query into a msgbox to see what's output I receive:

Select * from CIM_Datafile Where Drive =3D 'C:' AND Path =3D '\
\TransferTemp\\' AND FileName Like 'ABC_FILES%'

Re: Error 80041017 Looping through Array on Win 2000 by urkec

urkec
Fri Mar 14 10:54:01 CDT 2008

"requeth@gmail.com" wrote:

> > > >I have the following script running (snippet from full script) on a
> > > > Windows XP box with no errors. When I move the script to a Windows
> > > > 2000 box (production) I receive an error 80041017 on line with For,
> > > > character 1. All I've found online is that some of the winmgmt objects
> > > > are named differently in Win2K but I cant seem to find mine as a
> > > > problem. Does anyone see my problem?
> >
> > > > sSomefolder = filepath
> > > > 'sPathSpec = Replace(Mid(Dir, 3) & "\", "\", "\\")
> > > > sComputer = "." ' local machine
> > > > 'Queries the sSomefolder to find any files like the name in ivrpins.
> > > > 'This is necessary since the last characters before the extension are
> > > > different
> > > > Set qWMISrv = GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
> > > > Set aFiles = qWMISrv.ExecQuery("Select * from CIM_Datafile Where "_
> > > > & "Drive = 'C:' AND Path = '" & Dir1 & "' AND FileName Like '" _
> > > > & stamp_file & sqldate & "%'", , 48)
> >


LIKE operator was added for Windows XP, you can't use it on Windows 2000.

--
urkec

Re: Error 80041017 Looping through Array on Win 2000 by Tom

Tom
Fri Mar 14 11:55:33 CDT 2008

On Mar 14, 10:30 am, "requ...@gmail.com" <requ...@gmail.com> wrote:
> On Mar 14, 8:53 am, "requ...@gmail.com" <requ...@gmail.com> wrote:
>
>
>
> > On Mar 14, 8:46 am, "Richard Mueller [MVP]" <rlmueller-
>
> > nos...@ameritech.nospam.net> wrote:
> > > <requ...@gmail.com> wrote in message
>
> > >news:0ca7c656-331f-47d0-8bed-db672d0bae1d@d62g2000hsf.googlegroups.com...
>
> > > >I have the following script running (snippet from full script) on a
> > > > Windows XP box with no errors. When I move the script to a Windows
> > > > 2000 box (production) I receive an error 80041017 on line with For,
> > > > character 1. All I've found online is that some of the winmgmt objects
> > > > are named differently in Win2K but I cant seem to find mine as a
> > > > problem. Does anyone see my problem?
>
> > > > sSomefolder = filepath
> > > > 'sPathSpec = Replace(Mid(Dir, 3) & "\", "\", "\\")
> > > > sComputer = "." ' local machine
> > > > 'Queries the sSomefolder to find any files like the name in ivrpins.
> > > > 'This is necessary since the last characters before the extension are
> > > > different
> > > > Set qWMISrv = GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
> > > > Set aFiles = qWMISrv.ExecQuery("Select * from CIM_Datafile Where "_
> > > > & "Drive = 'C:' AND Path = '" & Dir1 & "' AND FileName Like '" _
> > > > & stamp_file & sqldate & "%'", , 48)
>
> > > > For Each File In aFiles
>
> > > > msgbox file.FileName
>
> > > The error means the query was invalid. Notice that Dir1, stamp_file, and
> > > sqldate have no values, and sSomefilder and filepath are not used. Also, the
> > > path (value of Dir1) should be similar to "\\Scripts\\MyFolder\\". Also, the
> > > FileName property does not include the extension.
>
> > > --
> > > Richard Mueller
> > > Microsoft MVP Scripting and ADSI
> > > Hilltop Lab -http://www.rlmueller.net
> > > --- Hide quoted text -
>
> > > - Show quoted text -
>
> > This is only a piece of my code, all values are filled in and work
> > properly on a Win XP Pro machine. It's when I move this to a 2000
> > Server that the script breaks.- Hide quoted text -
>
> > - Show quoted text -
>
> Here's a new example that's a little more complete:
>
> strComputer = "."
> Set objSWbemServices = _
> GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
>
> Dir1 = "\\TransferTemp\\"
> stamp_file = "ABC_FILES"
> Set colServices = _
> objSWbemServices.ExecQuery("Select * from CIM_Datafile Where "_
> & "Drive = 'C:' AND Path = '" & Dir1 & "' AND FileName Like '" _
> & stamp_file & "%'", , 48)
>
> For Each objService In colServices
> msgbox objService
> Next
>
> The directory C:\TransferTemp has 3 files named:
>
> ABC_FILES_20080306.TXT
> ABC_FILES_20080310.TXT
> ABC_FILES_20080312.TXT
>
> I want the script to pick these up and put them into an array so I can
> parse them out, but when I take this code out and put it into a
> seperate file, I receive an error on line 12 0x80041017 is the error
> code. Again this works on my Win XP machine and the directory
> structure/files are identicle.
>
> When I put the query into a msgbox to see what's output I receive:
>
> Select * from CIM_Datafile Where Drive = 'C:' AND Path = '\
> \TransferTemp\\' AND FileName Like 'ABC_FILES%'

I just remembered that the LIKE phase is not supported in Win 2K
queries.

I don't know of a workaround.

Tom Lavedas
===========

Re: Error 80041017 Looping through Array on Win 2000 by urkec

urkec
Sat Mar 15 01:58:00 CDT 2008

"urkec" wrote:

> "requeth@gmail.com" wrote:
>
> > > > >I have the following script running (snippet from full script) on a
> > > > > Windows XP box with no errors. When I move the script to a Windows
> > > > > 2000 box (production) I receive an error 80041017 on line with For,
> > > > > character 1. All I've found online is that some of the winmgmt objects
> > > > > are named differently in Win2K but I cant seem to find mine as a
> > > > > problem. Does anyone see my problem?
> > >
> > > > > sSomefolder = filepath
> > > > > 'sPathSpec = Replace(Mid(Dir, 3) & "\", "\", "\\")
> > > > > sComputer = "." ' local machine
> > > > > 'Queries the sSomefolder to find any files like the name in ivrpins.
> > > > > 'This is necessary since the last characters before the extension are
> > > > > different
> > > > > Set qWMISrv = GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
> > > > > Set aFiles = qWMISrv.ExecQuery("Select * from CIM_Datafile Where "_
> > > > > & "Drive = 'C:' AND Path = '" & Dir1 & "' AND FileName Like '" _
> > > > > & stamp_file & sqldate & "%'", , 48)
> > >
>
>
> LIKE operator was added for Windows XP, you can't use it on Windows 2000.

In windows 2000 you can use InStr or Left:

strComputer = "."
Set objSWbemServices = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Dir1 = "\\TransferTemp\\"
stamp_file = "ABC_FILES"

Set colServices = objSWbemServices.ExecQuery _
("Select * from CIM_Datafile "_
& "Where Drive = 'C:' " _
& "AND Path = '" & Dir1 & "'")

For Each objService In colServices
If Left(objService.FileName, 9) = stamp_file Then
WScript.Echo objService.Name
End If
Next

--
urkec