Read a file from a remote computer - WMI

Read a file from a remote computer - WMI

Post by TGlzY » Wed, 21 Apr 2004 18:51:04


Hi

Does anybody know how could I read a file from a remote computer using WMI with Windows 2000

Thanks in advance.
Greetings Lis
 
 
 

Read a file from a remote computer - WMI

Post by Sarika Sha » Thu, 22 Apr 2004 02:09:42

You can use cim_datafile.copy method to copy the file from remote machine to
local machine.

Then you can use filesystem object to open and read the file.

WMI does not provide any way to open/or read a file .

--
Sarika Sharma [MSFT]
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.yqcomputer.com/
Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.







with Windows 2000?

 
 
 

Read a file from a remote computer - WMI

Post by Jiachuan W » Thu, 22 Apr 2004 02:10:48

this script can easily read a remote file (but not using WMI though)



Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("\\jiawang05\d$\JIAWANG\public\failures.txt")
If objFile.Size > 0 Then
Set objReadFile =
objFSO.OpenTextFile("\\jiawang05\d$\JIAWANG\public\failures.txt", 1)
strContents = objReadFile.ReadAll
Wscript.Echo strContents
objReadFile.Close
Else
Wscript.Echo "The file is empty."
End If



--
This posting is provided "AS IS" with no warranties, and confers no rights.




with Windows 2000?
 
 
 

Read a file from a remote computer - WMI

Post by TGlzY » Fri, 23 Apr 2004 22:56:04

Hi Sarika and Jiachuan

Thank you very much for your replies

Sarika, I've tried with this script to copy a file from a remote computer to my computer: Acerel is my computer and pfc200 is the remote one.

Option Explici
Dim objFil
Dim numErrorCod
Dim objLocator, strCompute
strComputer="pfc200.dcom.upv.es
Set objLocator = CreateObject("WbemScripting.SwbemLocator"
Set objFile = objLocator.ConnectServer(strComputer).Get("CIM_DataFile='c:\Nube.log'"

numErrorCode = objFile.Copy("\\acerel.dcom.upv.es\c$\Caracola.log"
If numErrorCode = 0 the
WScript.Echo "File copied successfully
Else WScript.Echo "Copy failed with error code " & numErrorCod
End I
Set objFile = Nothin

But I get this error when I run the script: Copy failed with error 9, which means invalid object
Do you know what can be the problem
--------------------------------------------------------

Jiachuan, I've tried with this other script

Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objFile = objFSO.GetFile("\\pfc200.dcom.upv.es\c$\Nube.log"
If objFile.Size > 0 The
Set objReadFile =objFSO.OpenTextFile("\\pfc200.dcom.upv.es\c$\Nube.log", 1
strContents = objReadFile.ReadAl
Wscript.Echo strContent
objReadFile.Clos
Els
Wscript.Echo "The file is empty."
End I

But I get this error: file not foun

I think the problem can be in the way I write the path of the remote computer. I think I'm not using c$ rigth. Do I need some kind of permission or to activate anything? I dont know anything about UNC paths, but I will search information

Any comment will be helpfull

Thanks in advanc
Greetings Lis
 
 
 

Read a file from a remote computer - WMI

Post by Jiachuan W » Sat, 24 Apr 2004 01:08:14

If "the file is not found", just type sth directly in the cmd prompt or
browser addresss box to navigate and see whether that file exists or you've
the access permissions: \\pfc200.dcom.upv.es\c$\Nube.log

--
This posting is provided "AS IS" with no warranties, and confers no rights.




to my computer: Acerel is my computer and pfc200 is the remote one.
objLocator.ConnectServer(strComputer).Get("CIM_DataFile='c:\Nube.log'")
which means invalid object.
=objFSO.OpenTextFile("\\pfc200.dcom.upv.es\c$\Nube.log", 1)
computer. I think I'm not using c$ rigth. Do I need some kind of permission
or to activate anything? I don know anything about UNC paths, but I will
search information.
 
 
 

Read a file from a remote computer - WMI

Post by RMOpYm9yYW » Sat, 24 Apr 2004 17:26:04

Hi Jiachua

When I type \\pfc200.dcom.upv.es\c$\Nube.log in the command prompt I get this response: There's a duplicated name in the network

Any ideas? Thank you very muc

Greetings Dborah
 
 
 

Read a file from a remote computer - WMI

Post by Jiachuan W » Sun, 25 Apr 2004 01:43:34

type "\\pfc200.dcom.upv.es" in the explorer to see whether it can resolve
the server name (this seems the issue:) and whether you can see any
available share. (the remaining part just like a local path)

--
This posting is provided "AS IS" with no warranties, and confers no rights.




this response: There's a duplicated name in the network.