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

Re: Help with remote script by Roland

Roland
Mon Nov 07 10:53:07 CST 2005

<mark.unwin@gmail.com> wrote in message
news:1131334346.563077.259040@o13g2000cwo.googlegroups.com...
: Can anyone tell me why the below script works using the local computer
: name, but will not work using a remote computer name ?

<snip>

It would help if you included the reason why it doesn't work and an error
message if present. I would bet a permissions issue but no way to verify
that on this end.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: Help with remote script by mark

mark
Mon Nov 07 19:39:19 CST 2005

It's not permissions - I'm the Domain Admin.
Below is the output when run against another PC.

C:\inetpub\wwwroot\winventory\scripts>cscript "C:\Documents and
Settings\unwinm\
Desktop\moz2.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\hr371
l02.default
--------------------------
Calculated remote filename
\\ksit-qpcu\c$\documents and settings\smithk\application
data\mozilla\firefox\pr
ofiles\hr371l02.default\extensions\Extensions.rdf
--------------------------
C:\Documents and Settings\unwinm\Desktop\moz2.vbs(24, 3) (null):
0x80041002


Re: Help with remote script by Roland

Roland
Tue Nov 08 14:53:09 CST 2005

<mark.unwin@gmail.com> wrote in message
news:1131413959.885589.136980@g44g2000cwa.googlegroups.com...
: It's not permissions - I'm the Domain Admin.
: Below is the output when run against another PC.
:
: C:\inetpub\wwwroot\winventory\scripts>cscript "C:\Documents and
: Settings\unwinm\
: Desktop\moz2.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\hr371
: l02.default
: --------------------------
: Calculated remote filename
: \\ksit-qpcu\c$\documents and settings\smithk\application
: data\mozilla\firefox\pr
: ofiles\hr371l02.default\extensions\Extensions.rdf
: --------------------------
: C:\Documents and Settings\unwinm\Desktop\moz2.vbs(24, 3) (null):
: 0x80041002
:
It appears this is the line you're having an issue with:
split_folder = split(objFolder2.Name,"\",-1,1)

I believe your last two may be defaults. You should be able to just use:
split_folder = split(objFolder2.Name,"\")

If you put this before it:

wscript.echo objFolder2.Name
wscript.quit

What do you get for objFolder2.Name?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: Help with remote script by mark

mark
Tue Nov 08 21:50:46 CST 2005

Apologies for the delayed response.
My code says line 24 is:
For Each objFolder2 in colSubfolders2
not
split_folder = split(objFolder2.Name,"\",-1,1)
I did as you suggested, but it didn't make a difference. Same error.

Mark.


Re: Help with remote script by Roland

Roland
Wed Nov 09 04:13:47 CST 2005

<mark.unwin@gmail.com> wrote in message
news:1131508246.199072.11400@g43g2000cwa.googlegroups.com...
: Apologies for the delayed response.
: My code says line 24 is:
: For Each objFolder2 in colSubfolders2
: not
: split_folder = split(objFolder2.Name,"\",-1,1)
: I did as you suggested, but it didn't make a difference. Same error.

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.

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: Help with remote script by mark

mark
Wed Nov 09 23:15:10 CST 2005

OK.
First I tried just adding
wscript.echo "colSubfolders2" & colSubfolders2
wscript.quit
and I got
C:\>cscript "C:\Documents and Settings\unwinm\Desktop\moz2.vbs"
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\Documents and Settings\unwinm\Desktop\moz2.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 "C:\Documents and Settings\unwinm\Desktop\moz2.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 "C:\Documents and Settings\unwinm\Desktop\moz2.vbs"
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\Documents and Settings\unwinm\Desktop\moz2.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.....

Mark.


Re: Help with remote script by mark

mark
Wed Nov 09 23:19:49 CST 2005

Forgot - I checked the file permissions - Domain Admins are a member of
the Local Admins group. I am a Domain Admin. The folder & file in
question have Local Admins as full access. So i still don't think it's
permissions.....

BTW - the PC is my co-workers, who is also a Domain Admin. Nothing
special has been done to Users / Groups on the local box(his). We are
testing this for an addition to winventory.sf.net - my pet project.

Thanks for all you help.

Mark.


Re: Help with remote script by Roland

Roland
Thu Nov 10 02:13:11 CST 2005

<mark.unwin@gmail.com> wrote in message
news:1131599710.104904.31690@g43g2000cwa.googlegroups.com...
: Next I tried
: wscript.echo "colSubfolders2" & colSubfolders2.count
: wscript.quit
: and I got
: C:\>cscript "C:\Documents and Settings\unwinm\Desktop\moz2.vbs"
: Microsoft (R) Windows Script Host Version 5.6
: Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
:
: colSubfolders21

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.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: Help with remote script by mark

mark
Thu Nov 10 17:18:39 CST 2005

Whoops - wrong.
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\hr371
l02.default
--------------------------
Calculated remote filename
\\ksit-qpcu\c$\documents and settings\smithk\application
data\mozilla\firefox\pr
ofiles\hr371l02.default\extensions\Extensions.rdf
--------------------------
colSubfolders2 25
J: 2
C:\Documents and Settings\unwinm\Desktop\moz2.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 ?!?!?

Mark.


Re: Help with remote script by mark

mark
Thu Nov 10 18:04:17 CST 2005

25


Re: Help with remote script by Roland

Roland
Fri Nov 11 03:31:05 CST 2005

<mark.unwin@gmail.com> wrote in message
news:1131664719.212527.90620@g44g2000cwa.googlegroups.com...
: Whoops - wrong.
: 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\hr371
: l02.default
: --------------------------
: Calculated remote filename
: \\ksit-qpcu\c$\documents and settings\smithk\application
: data\mozilla\firefox\pr
: ofiles\hr371l02.default\extensions\Extensions.rdf
: --------------------------
: colSubfolders2 25
: J: 2
: C:\Documents and Settings\unwinm\Desktop\moz2.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

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: Help with remote script by mark

mark
Sat Nov 12 03:06:34 CST 2005

The script returns this:

c:\documents and settings\smithk\application
data\mozilla\firefox\profiles

Mark.


Re: Help with remote script by mark