home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2226
Discussions: 186,676, Posts: 2,227,797, Members: 230,320
Free Scan: Update Your PC's Outdated Drivers to Optimize Performance
Old October 13th, 2008, 03:03 PM   Digg it!   #1 (permalink)
Senior Member
 
bwcc's Avatar
 
Join Date: Nov 2001
Location: Central KS
Posts: 830
VB/WMI help : copy files between 2 PCs

I'm having difficulty with my script which will should copy files between 2 different PC's.

Code:
strComputer = "."
set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _ 
    ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _ 
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _ 
            & "TargetInstance.GroupComponent= " _ 
                & "'Win32_Directory.Name=""\\\\\\\\data\\\\users\\\\test""'")  
Do 
    Set objLatestEvent = colMonitoredEvents.NextEvent    
    strFile = objLatestEvent.TargetInstance.PartComponent 
    strFile = Replace(Mid(strFile, InStr(strFile, Chr(34)) + 1), "\\", "\") 
    strFile = Left(strFile, Len(strFile) - 1) 
    objFSO.CopyFile strFile, "c:\test\" 
Loop
Using the local connection above, it doesn't seem that I can use a UNC connection line in Win32_Directory.Name. However, if I change "\\\\\\\\data\\\\users\\\\test" to "Z:\\\\test" (by mapping \\data\users to Z: ), it will work fine. But I don't want to use mapped drive letters.

If I change strComputer to create a remote connection to the remote machine:

Code:
strComputer = "remotemachine"
set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _ 
    ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _ 
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _ 
            & "TargetInstance.GroupComponent= " _ 
                & "'Win32_Directory.Name=""c:\\\\test""'")  
Do 
    Set objLatestEvent = colMonitoredEvents.NextEvent    
    strFile = objLatestEvent.TargetInstance.PartComponent 
    strFile = Replace(Mid(strFile, InStr(strFile, Chr(34)) + 1), "\\", "\") 
    strFile = Left(strFile, Len(strFile) - 1) 
    objFSO.CopyFile strFile, "\\data\test\" 
Loop
The code runs fine until the loop, which returns a disk not ready error when it tries to copy the file. Permissions on \\data\test are set to Everyone - Full. I have also tried "\\data\users\test" and "\\data\c$\users\test\"

The end result I am looking for is:

Have a script run every so often on the server (data) and check for new files on 5 remote stations. If a new file is found, copy it to the server.

Any help on this would be appreciated.

TIA
__________________
Im against picketing, but I dont know how to show it.

bwcc is offline   Reply With Quote
TechIMO.com Ads - Login or register for less ads.
How many errors does your computer have?

You no longer need to guess! This free stability scan and registry cleaner download will give you a complete diagnosis of your Windows registry, identifying errors and conflicts.

FREE instant scan


Guest, Register Free! to remove this ad and get your tech support questions answered in minutes!
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
no copy when move files c: -> d: JacobM5727 Technical Support 10 May 28th, 2008 07:21 AM
Some files can not be copy BluesMan1 Applications and Operating Systems 8 December 28th, 2005 10:27 AM
copy files from subdirectories? VHockey86 Applications and Operating Systems 4 May 12th, 2004 05:17 PM
Copy files from Red Hat to XP homerz Linux and Unix 7 October 25th, 2003 02:37 PM
copy files from CD to harddrive isup Storage Related 5 June 10th, 2003 11:04 PM

Most Active Discussions
Is It Just Me? (654)
Best Boot Drive Imaging Software (7)
Video card compatability. (7)
File associations (5)
Bought an AGP "HIS Radeon HD 3.. (18)
Is this a good laptop for gamming? (6)
Outlook add-in won't remove. (10)
Presario Help (6)
Misery Loves Company... (1873)
Recent Discussions
graphics card driver issue (0)
What graphics card range for q9.. (1)
Can't print from IE7 (3)
File associations (5)
Sidewindow for case (1)
Best Boot Drive Imaging Softwar.. (7)
*TechIMO's Top 30 PCs* (0)
Empire: Total War (6)
Advice needed for building a ga.. (7)
Seald copy of windows 95 for sa.. (1)
Magellan RoadMate 1412 GPS Perf.. (2)
FS: Dell 6000 laptop, modded 36.. (2)


All times are GMT -4. The time now is 08:09 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28