===================================
===================================
Can anyone tell me why the below script works using the local computer
name, but will not work using a remote computer name ?
Thanks in advance,
Mark.
strComputer = "mark"
folder = "c:\documents and settings"
dim folder_array(20)
dim folder_array_2(20)
i = -1
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colSubfolders = objWMIService.ExecQuery ("Associators of
{Win32_Directory.Name='" & folder & "'} Where AssocClass =
Win32_Subdirectory ResultRole = PartComponent")
For Each objFolder in colSubfolders
folder = split(objFolder.Name,"\",-1,1)
moz_folder = "\\" & strComputer & "\c$\documents and settings" & "\"
& folder(2) & "\application data\mozilla\firefox\profiles"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(moz_folder) Then
i = i + 1
folder_array(i) = objFolder.Name & "\application
data\mozilla\firefox\profiles"
folder_array_2(i) = moz_folder
end if
Next
For i = 0 to UBound(folder_array)
Set colSubfolders2 = objWMIService.ExecQuery ("Associators of
{Win32_Directory.Name='" & folder_array(i) & "'} Where AssocClass =
Win32_Subdirectory ResultRole = PartComponent")
For Each objFolder2 in colSubfolders2
split_folder = split(objFolder2.Name,"\",-1,1)
wscript.echo "Returned (local) directory"
wscript.echo objFolder2.Name
wscript.echo "--------------------------"
moz_folder_2 = folder_array_2(i) & "\" & split_folder(7) &
"\extensions\Extensions.rdf"
wscript.echo "Calculated remote filename"
wscript.echo moz_folder_2
wscript.echo "--------------------------"
Set objTextFile = objFSO.OpenTextFile(moz_folder_2, 1)
Do Until objTextFile.AtEndOfStream
input_string = objTextFile.ReadLine
MyPos = Instr(1, input_string, "<RDF:Description")
if MyPos > 0 then
Do Until objTextFile.AtEndOfStream
input_string2 = objTextFile.ReadLine
MyPos2 = Instr(1, input_string2, "</RDF:Description>")
if MyPos2 > 0 then exit do
MyArray = Split(input_string2, chr(34), -1, 1)
if Instr(1, MyArray(0), "em:version=") then version =
MyArray(1)
if Instr(1, MyArray(0), "em:name=") then name = MyArray(1)
if Instr(1, MyArray(0), "em:description=") then description =
MyArray(1)
if Instr(1, MyArray(0), "em:creator=") then creator =
MyArray(1)
if Instr(1, MyArray(0), "em:homepageURL=") then homepage =
MyArray(1)
Loop
wscript.echo "--------------------"
wscript.echo "Name: Mozilla Firefox Extension - " & name
wscript.echo "Version: " & version
wscript.echo "Description: " & description
wscript.echo "Creator: " & creator
wscript.echo "Homepage: " & homepage
name = ""
version = ""
description = ""
creator = ""
homepage = ""
end if
Loop
Next
Next
Below is the output when run against another PC.
C:\>cscript mozilla_extensions.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
Returned (local) directory
c:\documents and settings\smithk\application
data\mozilla\firefox\profiles\hr371l02.default
--------------------------
Calculated remote filename
\\ksit-qpcu\c$\documents and settings\smithk\application
data\mozilla\firefox\profiles\hr371l02.default\extensions\Extensions.rdf
--------------------------
C:\mozilla_extensions.vbs(24, 3) (null): 0x80041002
===================================
===================================
If you put this before the 'For Each' line:
wscript.echo "colSubfolders2" & colSubfolders2
wscript.quit
If it's a collection, you can use colSubfolders.count
If it's an array, you can use ubound(colSubfolders)
It appears you get an error on the 'For Each' line because nothing is
returned. If you we can prove that, all you need is a conditional to
test if it's empty. That would explain why it works on one system and
not another.
When something is returned empty but it shouldn't be, then it's a
permissions issue. It doesn't matter if you're part of the domain
admin group or not. If I have local admin privs, I can block the
domain admin group from accessing my system by just removing them from
the local administrator's group so being part of a group is not enough.
You have to know what the effective rights are for a given path to
know if it really is a permission's issue or not. That user, local or
global group can have explicit rights and they can be anything,
including set to no access, while still having access elsewhere.
Clearly this is not the norm but it is a requirement to verify it.
===================================
===================================
OK.
First I tried just adding
wscript.echo "colSubfolders2" & colSubfolders2
wscript.quit
and I got
C:\cscript mozilla_extensions.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
C:\mozilla_extensions.vbs(25, 3) Microsoft VBScript runtime error:
Wrong number of arguments or invalid property assignment
Next I tried
wscript.echo "colSubfolders2" & colSubfolders2.count
wscript.quit
and I got
C:\>cscript mozilla_extensions.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
colSubfolders21
Then I tried
wscript.echo "colSubfolders2" & ubound(colSubfolders2)
wscript.quit
and I got
C:\>cscript mozilla_extensions.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
C:\mozilla_extensions.vbs(25, 3) Microsoft
VBScript runtime error: Wrong number of arguments or invalid property
assignment
So does that help ???
Looks like it returns a collection to me. But I'm none the wiser as to
how to fix the issue.....
===================================
===================================
Yes that helps. I should have told you to use "colSubfolders2: " &
colSubfolders2.count but I messed up.
Ok, so 21 matches in that collection.
Let's add another variable since we're only getting the first run on
the loop.
On the 'dim' statement in the beginning add: ,j
So it reads: dim folder_array(20), j
Then before the line 'For Each' put in:
j = j + 1 : wscript.echo j
Tell me what number j is when it fails.
===================================
===================================
Here it is - it looks like this in the code - no wscript.quit
wscript.echo "colSubfolders2 " & colSubfolders.count
j = j + 1 : wscript.echo "J: " & j
Output is
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
colSubfolders2 25
J: 1
Returned (local) directory
c:\documents and settings\smithk\application
data\mozilla\firefox\profiles\hr371l02.default
--------------------------
Calculated remote filename
\\ksit-qpcu\c$\documents and settings\smithk\application
data\mozilla\firefox\profiles\hr371l02.default\extensions\Extensions.rdf
--------------------------
colSubfolders2 25
J: 2
C:\mozilla_extensions.vbs(29, 3) (null):0x80041002
So maybe it's hitting a folder without the needed "\application
data\mozilla\firefox\profiles" and returning NULL - which makes the
script barf ?!?!?
===================================
===================================
I just noticed in my earlier statement that there was only 1 return,
not 21 and then we told the script to quit.
Ok, let's see what's in your first array. After the first FOR
EACH..NEXT loop, put this and then verify the paths.
wscript.echo join(folder_array,vbCrLf)
wscript.quit
===================================
===================================
The script returns this:
c:\documents and settings\smithk\application
data\mozilla\firefox\profiles