List Folders on a remote computer

Hello guys, 

I am new to scripting and my first task is to list folders on several remote
machines, 1 is in my local workgroup, one is outside my network (accessible
IP address), I have admin account on both.

I need to list all folders in the root of remote drive C: on both.

Whatever I do I seem to get the  permission denied get object error.

Any idea?

2
BrunoBozic
10/6/2010 7:32:39 AM
scripting.vbscript 564 articles. 0 followers. Follow

5 Replies
4723 Views

Similar Articles

[PageSpeed] 17


"BrunoBozic" <u65408@uwe> wrote in message news:af1a2d9447a0d@uwe...
> Hello guys,
>
> I am new to scripting and my first task is to list folders on several 
> remote
> machines, 1 is in my local workgroup, one is outside my network 
> (accessible
> IP address), I have admin account on both.
>
> I need to list all folders in the root of remote drive C: on both.
>
> Whatever I do I seem to get the  permission denied get object error.
>
> Any idea?

Well, the first thing would be to tell us what you did that got the 
permission denied error.

/Al
 

0
Al
10/8/2010 4:23:18 AM
Hi Al, heres some extra info on my problem:

I am using VBSEDIT as a IDE for this project.
I am using the following example script; 

SCRIPT START
strComputer = "COMPUTER-A"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery("Select * from CIM_Datafile")

For Each objFile in colFiles
    Wscript.Echo objFile.Name
Next
SCRIPT END

The access denied error happens on line 2 (logging in).

There are 2 computers involved in this test, both running windows 7, both
have no firewall, both have no shared folders, both have the same
administrator account (lets call it MyAdmin/MyPassword). The computers are
not members of a domain, but are in the workgroup.

COMPUTERA throws "accesss denied" error when connecting to COMPUTER B,
COMPUTER B successfully runs the script on COMPUTERA.

Both are using "impersonate" method. By looking at the documentation,
impersonating ought not to work on a workgroup, only "identify" method. I am
left wondering why B connects to A and runs the script by impersonating. 

I tried sorting this out by changing permissions for DCOM object to allow
just about everyone to run remote access and I fixed the problem
(impersonating now works both ways on a workgroup) but now I made the system
(luckily its a test system) vulnerable to intrusion.

Basically I would be most thankfull if you could give me some advice on how
to achieve the following

Task:
1) workgroup computers, 20x, same local administrator account on 10,
different one other 10
2) out of the box Win7 installations on each
3) need to run the script on all of them

(Local admin accont name: TESTADMIN/TESTPASSWORD)
(Different admin account name on 10 of computers: TADMIN/TADMIN)
(Workgroup name: TESTWORKGROUP)
(Computer names: TEST1, TEST2 ... etc.)

Problem:
1) I will need to pass (via identify) login/password for those computers,
need an example (tried and tested)
2) I dont want to change any system setting, I need it to work without
changing UAC setting/DCOM and WMI settings or making changes to existing
admin accounts)
3) script has to run on all of them and return information to the calling
computer

I am a software developer, unfortunately I am relatively network
administratin agnostic, and I know I should know how Windows handle security
over domains and over workgroups, but I never had to work with it in the past,
my latest task is to make scripts in vbscript for administrators and I am
doing my best but...  ;)

-- 
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forums.aspx/vbscript/201010/1

0
BrunoBozic
10/8/2010 8:53:58 AM

"BrunoBozic via WebmasterKB.com" <u65408@uwe> wrote in message 
news:af3408ad4b5b6@uwe...
> Hi Al, heres some extra info on my problem:
>
> I am using VBSEDIT as a IDE for this project.

That is immaterial, assuming you run the script directly.

> I am using the following example script;
>
> SCRIPT START
> strComputer = "COMPUTER-A"
> Set objWMIService = GetObject("winmgmts:" _
>    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set colFiles = objWMIService.ExecQuery("Select * from CIM_Datafile")
>
> For Each objFile in colFiles
>    Wscript.Echo objFile.Name
> Next
> SCRIPT END
>
> The access denied error happens on line 2 (logging in).
>
> There are 2 computers involved in this test, both running windows 7, both
> have no firewall, both have no shared folders, both have the same
> administrator account (lets call it MyAdmin/MyPassword). The computers are
> not members of a domain, but are in the workgroup.

What account are you using to run this script, the administrator account?

> COMPUTERA throws "accesss denied" error when connecting to COMPUTER B,
> COMPUTER B successfully runs the script on COMPUTERA.

I assume the scripts are identical in both cases...

> Both are using "impersonate" method. By looking at the documentation,
> impersonating ought not to work on a workgroup, only "identify" method. I 
> am
> left wondering why B connects to A and runs the script by impersonating.

I am more familiar with a domain environment. I have a workgroup setup at 
home, and have run into some permission anomalies from computer to computer.

> I tried sorting this out by changing permissions for DCOM object to allow
> just about everyone to run remote access and I fixed the problem
> (impersonating now works both ways on a workgroup) but now I made the 
> system
> (luckily its a test system) vulnerable to intrusion.

Not an ideal or practical solution...

> Basically I would be most thankfull if you could give me some advice on 
> how
> to achieve the following
>
> Task:
> 1) workgroup computers, 20x, same local administrator account on 10,
> different one other 10

Ack, why different?

> 2) out of the box Win7 installations on each
> 3) need to run the script on all of them

That is not your primary need, just what you envision as a way to get what 
you need. What is it that you really need to do?

> (Local admin accont name: TESTADMIN/TESTPASSWORD)
> (Different admin account name on 10 of computers: TADMIN/TADMIN)
> (Workgroup name: TESTWORKGROUP)
> (Computer names: TEST1, TEST2 ... etc.)
>
> Problem:
> 1) I will need to pass (via identify) login/password for those computers,
> need an example (tried and tested)
> 2) I dont want to change any system setting, I need it to work without
> changing UAC setting/DCOM and WMI settings or making changes to existing
> admin accounts)
> 3) script has to run on all of them and return information to the calling
> computer

Since an identical script works from A to B but not from B to A, there 
*must* be something different in the configuration. I'm not expert in WMI, 
so I'm not sure what the error really means in this context. I'd suggest you 
try listing the directory interactively from a command prompt window with 
this command:

    dir /ad \\othercomputer\c$

If this fails in the same way, that would tend to confirm that it is some 
configuration difference causing the issue. If, on the other hand, that 
works, you might consider a non-wmi solution. This could be:

- a batch file using the above command
- a vbscript script using .run or .exec to execute the equivalent dir 
command
- a vbscript that iterates through a file system folder object associated 
with the remote hard drive.

If the interactive dir command works, all three of the above should also 
work.

/Al
 

0
Al
10/9/2010 3:10:04 AM
>What account are you using to run this script, the administrator account?

Yes.


>I assume the scripts are identical in both cases...


They are.


>I am more familiar with a domain environment. I have a workgroup setup at 
>home, and have run into some permission anomalies from computer to computer.


Thats bad news for me :)


>> 1) workgroup computers, 20x, same local administrator account on 10,
>> different one other 10
>
>Ack, why different?


Dont know, thats how things are on our network. This means I will be using a
txt file list of computers together with login/password, and will need an
example of how to pass login and password through a vbs script to a specific
computer via identify method.



>That is not your primary need, just what you envision as a way to get what 
>you need. What is it that you really need to do?

I need to be able to achieve the following tasks:
1) enumerate internet explorer cache, delete it file by file, report this to
excel
2) find out remote comps OS, version of IE, and header footer settings for IE,
report into excel
3) check a range of folders for huge tmp files, report this to excel
4) ping each comp before creating wmi object to it, report this to excel





>Since an identical script works from A to B but not from B to A, there 
>*must* be something different in the configuration. 


Yeah, thats the worst case situation for troubleshooting it, I really need to
know if out of the box workgroup clients can be accessed via this kind of
script ... without any changes having to be made...

-- 
Message posted via WebmasterKB.com
http://www.webmasterkb.com/Uwe/Forums.aspx/vbscript/201010/1

0
BrunoBozic
10/9/2010 9:19:52 AM

"BrunoBozic via WebmasterKB.com" <u65408@uwe> wrote in message 
news:af40d54d0510a@uwe...

<snip>

>>That is not your primary need, just what you envision as a way to get what
>>you need. What is it that you really need to do?
>
> I need to be able to achieve the following tasks:
> 1) enumerate internet explorer cache, delete it file by file, report this 
> to
> excel
> 2) find out remote comps OS, version of IE, and header footer settings for 
> IE,
> report into excel
> 3) check a range of folders for huge tmp files, report this to excel
> 4) ping each comp before creating wmi object to it, report this to excel

So it would appear that the task of listing folders on the C: drive of 
remote computers is not the primary goal, just a task to get you started 
with the above more significant tasks...

But now that you have indicated at least some of your actual requirements, 
not that there is no mention of Vbscript, and only one mention of WMI. You 
might find that there are other methodologies that could be used. Some might 
be simpler to achieve in some cases - what you really want is to have one 
approach that will meet all of your current (and future) requirements.

Here are some possible alternatives you might consider looking into:

- vbscripts run on remote systems using psexec.exe
- batch files run on remote systems using psexec.exe
- powershell scripts

Since your tasks all seem to be geared towards encouraging or enforcing 
standard configurations, perhaps you might consider moving to a domain 
environment. This would provide a more level playing field in which all 
permissions, access restrictions, and configurations can be centrally 
managed.

>>Since an identical script works from A to B but not from B to A, there
>>*must* be something different in the configuration.
>
>
> Yeah, thats the worst case situation for troubleshooting it, I really need 
> to
> know if out of the box workgroup clients can be accessed via this kind of
> script ... without any changes having to be made...

I thought you said these were out of the box win7 workgroup clients. If so, 
you have already proven there can be problems. If not, you have already 
proven that you do not have full control of the workstation configurations 
that might be required to maintain them in a state where you can readily 
manage them with WMI scripting.

/Al
 

0
Al
10/10/2010 5:34:40 PM
Reply:

Similar Artilces:

moving outlook to a new computer
A sudden and unexpected component fault(graphics chip) on the motherboard of my laptop necessitated the purchase of a new laptop. I had not backed up any data from the old machine, but have now restored all my documents and files via an external hard drive adaptor. Unfortunately I'm struggling to transfer my Outlook data to the new laptop from the old drive. I have followed the Import/Export wizard in Outlook to import the .pst file after saving it from the old hard drive, but just get the following message "This Personal Folder file (.pst) is already in use in the curre...

Cannot move emails between folders
I am the Administrator on my home machine. If I try to move an email from the Inbox to another folder I am told 'I don't have permission, check the folder properties for permission' There is nothing in the folder properties about permissions. This has only recently started happening. XP Home and Outlook XP with all updates. ...

Smart List problem
I recently re-installed a client (version 9.0). Everything went fine but when we tried to open Smartlist on this client we got an error message telling us that “To use Smartlist capability in this product the Smartlist tables must be built. This is one time initialization process and may take a few minutes”. I answered yes, it ran and then returned the following error “number of columns does not match table definitions”. Every other machine is working fine, is the tables it is talking about building on the client? It does not seem like that should be so. It does not matter ...

Sent Items to Public folder?
Hi How can I synch user's sent itmes to a particular public folder? Thanks Himalyas wrote: > Hi > > How can I synch user's sent itmes to a particular public folder? > > Thanks No syncing is possible. You could use a rule for this. If this is a mail-enabled public folder and you have multiple people accessing it/using Send As for it, consider using a shared mailbox instead...and see www.ivasoft.biz. Thanks for help. Could you please suggest me good book on public folders and exchange 2003 in general? I have not touched exchange since 5.5. "Lanwench [MVP - ...

Cloning a price list
Is there any way either through the standard user interface or through the CRM SDK to clone an entire price list? TIA Not an option under standard UI Need to use SDK. Good luck. Frank Lee Workopia, Inc. http://www.workopia.com/Links.htm San Francisco, CA "JB" wrote: > Is there any way either through the standard user interface or through > the CRM SDK to clone an entire price list? > > TIA > > ...

custom address list for EXTERNAL email addresses
I know it is possible to create a custom address list in Exchange 2003 for internal use but how about for external email addresses outside of a company? Is this possible?? Any help would be appreciated. Thanks in advance. Create contacts for each of the external mail addresses and add them to the distribution list. If add a valid internet email address to the distribution list external people can also send to it. Glen "Steven Peters" <Steven Peters@discussions.microsoft.com> wrote in message news:CBF2F2AE-ABF4-491C-836C-59611375F9F1@microsoft.com... > I know it is pos...

Exchange database folder
Hi! I have just installed Exchange 2003 on windows 2003 server and all files (database, mailboxes....) are installed on drive "c:". How could move all on drive "e:" ? Thanks Antonio Grasso Hi Open ESM, navigate to the server -> Mailbox Store -> Properties -> -> Database TAB Click "Brows" for Exchange Database file and brows to the new location Do the same fore the Exchange streaming file Click Apply, after move process finished you notify for it It is highly recommended that you move the Transaction Log to another location then The operatio...

Rename/Delete/Deactivate Junk Mail Folder
Hi! Does somebody know how I can delete/rename or deactivate the Junk Mail folder in Outlook 2003? If I delete this folder, it will be re-created in the next Outlook start. I've read that Junk Mail folder is an built-in and cannot be renamed/deleted or deactivated?! Please help! Thanks Mustafa That is correct. Why do you need to get rid of it/rename it? -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -What do the Outlook Icons Mean? -Create an Office 2003 CD slipstreamed with Service Pack 1 ----- "mustafa" <mustafa@discussions.microsoft.com&g...

Identifying remote Outlook Access
Scenario. I am running outlook 2002 on NT4.0 connected to exchange mailbox on exchange 5.5/2000. Is there any way I can identify whether the Administrator or exchange Admin has my mailbox open on his PC or is accessing my mailbox via his security access. Can i tell on my PC. Is there something left locally on my PC that will tell me. No, you can't. Why the suspicion? -- Roady [MVP] www.sparnaaij.net Microsoft Office and Microsoft Office related News Also Outlook FAQ, How To's, Downloads and more... Tip of the month: -Create your own fully customized Toolbar Subscribe to the...

Comparing first and last names in two lists
I have two data sources that each contain about 8000 names in seperate fields for first and last name. I can put them on seperate worksheets or append one to the other. I need to make them match and find out where they don't. Messed with consolidate but not sure if that will work for more than one column at a time. FYI data set one is from a school transportation database and data set two is from the main student database from the same school district. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages dir...

How to remove the exchange public folder?
Hi, We have exchange 5.5 running in our organization. We remove one site from the current organization and would like to know, how can we remove the public folders which replicated when it was on the organization with other sites. Thanks >-----Original Message----- >Hi, > >We have exchange 5.5 running in our organization. We >remove one site from the current organization and would >like to know, how can we remove the public folders which >replicated when it was on the organization with other >sites. > >Thanks >. >you need to open exchange in raw ...

I deleted my Public Folder under IIS By Mistake
I have deleted my Public Folder Virtual Folder in the IIS Manager by Mistake How can I re-create this so that users can use the Public Folders through OWA again Any help Cheers, You have a back up strategy every night right? If so copy it from the back up, if not, you need to have all of yoru databases log files. try this; http://support.microsoft.com/default.aspx?scid=kb;en-us;313184 ...

Clear Junk E-mail Folder
It seems that rule cannot be set to remove messages from Junk E-mail Folder on exit Outlook. Is there any way to do that? Thanks. I'm using OL2003. ...

Category to Distribution List
Dear All: A: Outlook 2003 B: OS = XP Is there a way to create a Distribution List from a category ? I have a number of clients in special categories ( usually company name) However, there are times when I want to send BCC to several clients and would like to find a way to send that email without having to insert all the names. The category list of names can only be in the To: portion of the outgoing email. Suggestions highly appreciated. John A Hansen Two methods, both starting with the folder grouped by category, and all = the items in the category selected:=20 1) Choose Actions |...

List control selction and deselection
For selecting an item from a CListCtrl just call mList.SetItemState(iItem,LVIS_SELECTED | LVIS_FOCUSED, 0xFF) during Initialization For deslecting we need to insert item once again, ie mList.DeleteAllItems() mList.InsertItem() i know this is not a good method, but i didnt get any other options. if anyone know, pls let me know!!! Regards "johnWins" <johnsvakel@gmail.com> wrote in message news:2ccf2c5c-eb5c-46fd-9bd5-30d89d2048f6@v67g2000hse.googlegroups.com... > For selecting an item from a CListCtrl just call > > mList.SetItemState(iItem,LVIS_SELECTED | LV...

Stop use of Distribution List
Is there anyway that you can stop, or restrict the use of a distribution list? Since you have so much detail of how you are setup and if there are specific people or groups you want to restrict from using it, I will answer your question with the same amount of detail....YES. Add more detail and we can give you a better answer. "brendanrtw" <brendanrtw@discussions.microsoft.com> wrote in message news:6CB3EB2F-F428-46AD-A41E-A1495B8CF4CD@microsoft.com... > Is there anyway that you can stop, or restrict the use of a distribution > list? On Thu, 3 Nov 2005 12:00:...

Hyperlnk to a cd-rom folder
How but a exel file that has hyper links to the folders on that cd rom with out naming a drive letter since everyone has a different drive letter for their cd rom??? Thanks The excel workbook is stored on that same CD? If yes, this worked ok for me in xl2002 and using my harddrive (not CDROM). File|properties Hyperlink Base: \ (just the backslash) Then I could insert hyperlinks via Insert|Hyperlink and just leave the drive letter off. If the workbook is not on the same cd, you could have a file on the cd to look for, search the CDdrives and determine the drive letter. Then have your mac...

Public Folder is missing objects
I made a mistake. I was migrating from one Exchange 2003 server to another Exchange 2003 server. These were the only two servers in my structure. When I installed the second, I did not give it enough time to properly replicate all of the public folder data before I uninstalled it. Now, my public data folder on my only exchange server is corrupt. The primary indication of this (besides that I have no public folders visible in Outlook), is an error message when I click Send/Receive: "Task 'jaraco.com' reported error (0x8004010F): 'The operation failed. An object could not b...

can not move files and folders on vista
hi, I am having problem moving any type of files or folders to different place. I cannot even move a file in my document to a folder in my document. can any one help please. I tried setting the admin but that did not resolve it. I am using vista. However, I can delete and rename files and floders but just can't move them -- lovelacews Not a Windows Live Mail issue. Please post here. Windows Vista General Newsgroup. In your newsreader: news://msnews.microsoft.com/microsoft.public.windows.vista.general On the Web: http://www.microsoft.com/communities/newsgroups/en-u...

received mail goes directly to "deleted items" folder
When getting new mail, the mail goes directly to the "Deleted Items" folder instead of the "Inbox". Any suggestions? ...

selecting multiple choices from a drop down list
I have a drop down list in a cell and I want to be able to selec multiple entries from that list. Does anyone know how I go this -- Message posted from http://www.ExcelForum.com If this is a data validation list, you could use code to compile a list of selected items. For example, if the data validation is in column C, the following code will store the selected items in the same row in column D: '============================= Private Sub Worksheet_Change(ByVal Target As Range) Dim rngDV As Range Application.EnableEvents = False If Target.Count > 1 Then Exit Sub On Error Resume N...

List Running Horizontally-Pivot Table Possible?
I just had a customer ask this one and I'm not so sure about it. 1) The customer has setup a list of information that is running horizontally instead of the typical list running vertically. 2) I just taught him how to do pivot tables and he wants to generate a pivot table with his "horizontal" list. 3) I know he can copy and paste special and use the Transpose feature to change the list from horizontally oriented to vertically oriented. 4) the question is: can he leave the table in its original orientation and still generate Pivot tables? I can't seem to make it work ...

Copying Publisher from One computer to another
I want to copy Publisher from my old computer to my new one, but if I can't seem to locate all the files I need to make it work on the new computer. What should I do? You can't, you have to install it from the CD. -- ~~~~~~~~~~~~~~~~~~ Rob Giordano Microsoft MVP Expression "Jasmin" <Jasmin@discussions.microsoft.com> wrote in message news:7EB558F1-525D-47BD-A54B-BC62C410D79E@microsoft.com... |I want to copy Publisher from my old computer to my new one, but if I can't | seem to locate all the files I need to make it work on the new computer. What | shoul...

tasks entered in taskpad don't appear in task folder
All of the tasks that I have entered via the taskpad do not appear in the task folder, what am I doing wrong or do I have the wrong expectation? OL98/WinXP John Keith kd0gd@juno.com What view are you using on your Tasks folder? --=20 Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. "John Keith" <kd0gd@juno.com> wrote in message = news:6grrm0hkagessu2ecc0bj81pc41aarq39r@4ax.com... | All of the tasks that I have...

List folders to file
Hi Does anyone have a macro that would list all the folders (with path) and subfolders to an excel sheet but not the files? Thanks Shona Shona- There's a function called CELL() that should return your filename (or any of a number of parameters) but I can't get it to work properly on my machine, so I can't make it work for you. The syntax is =CELL("filename") which ought to return the path and filename of the current file, and which you could then trim down to show just the path. Can anyone provide some guidance here? Dave, If it isn't working for you, it pro...