1) We have a script that maps and unmaps drives.
This script is an audit script. So it is called say from Box1 to
BoxA, BoxB, BoxZ etc...
To find out where BoxA-BoxZ have been running backups, the script
interrogates
the backup logs on BoxA-BoxZ.

To read the BoxA-BoxZ the script maps a drive ( V: in this instance)

objNetwork.MapNetworkDrive "V:", "\\" & strComputer & "\" & "C$", ,
strUser, strPwd
and open to read the back up logs
strFilePath = "V:\Program Files\Tivoli\TSM\baclient
\dsmsched.log"

When finished the drive gets disconnected/unmapped.

If there multiple script jobs running concurrently, this could be a
problem as there could be a job querying the log file as the volume
could have been dismounted from another job.

What would be the best way to read the log on a server without
mounting the drives?

2) Another reason for mounting the drives,
there are some windows commands like "ipconfig" we usually run the
command, save as a text file
errReturn = objProc.Create ("cmd.exe /c ipconfig > C:\temp
\ipview.txt", Null, Null, intPID)

Is there a better way of executing command and read the output
directly without having to creating an extra file?

Re: How to read text files on remote servers without mapping/unmapping drives? by Pegasus

Pegasus
Wed Mar 19 16:16:53 CDT 2008


<Hoa.Hoa.Nguyen@gmail.com> wrote in message
news:df8d01cc-320b-46c1-a5c2-3df747201d55@m36g2000hse.googlegroups.com...
> 1) We have a script that maps and unmaps drives.
> This script is an audit script. So it is called say from Box1 to
> BoxA, BoxB, BoxZ etc...
> To find out where BoxA-BoxZ have been running backups, the script
> interrogates
> the backup logs on BoxA-BoxZ.
>
> To read the BoxA-BoxZ the script maps a drive ( V: in this instance)
>
> objNetwork.MapNetworkDrive "V:", "\\" & strComputer & "\" & "C$", ,
> strUser, strPwd
> and open to read the back up logs
> strFilePath = "V:\Program Files\Tivoli\TSM\baclient
> \dsmsched.log"
>
> When finished the drive gets disconnected/unmapped.
>
> If there multiple script jobs running concurrently, this could be a
> problem as there could be a job querying the log file as the volume
> could have been dismounted from another job.
>
> What would be the best way to read the log on a server without
> mounting the drives?
>
> 2) Another reason for mounting the drives,
> there are some windows commands like "ipconfig" we usually run the
> command, save as a text file
> errReturn = objProc.Create ("cmd.exe /c ipconfig > C:\temp
> \ipview.txt", Null, Null, intPID)
>
> Is there a better way of executing command and read the output
> directly without having to creating an extra file?

1) You could use the objFSO object to open a file, using the
UNC naming convention ("\\Server\Share\FileName.Ext").
2) You could use the .exec method to read the output from ipconfig
without an intermediate file:
Set ObjWshShell = WScript.CreateObject("WScript.Shell")
Set ObjExec = ObjWshShell.Exec("ipconfig.exe /all")
Do While Not ObjExec.StdOut.AtEndOfStream
WScript.Echo ObjExec.StdOut.ReadLine 'Read a line
Loop



RE: How to read text files on remote servers without mapping/unmapping by CoreyThomasMCSEMCSAMCDBA

CoreyThomasMCSEMCSAMCDBA
Wed Mar 19 16:19:01 CDT 2008

Hi,

Instead of using the drive letter, use the full UNC path. For example:

Instead of using V:\Program Files\Tivoli\TSM\baclient\dsmsched.log
Use \\myserver\c$\Program Files\Tivoli\TSM\baclient\dsmsched.log

For the ipconfig, you can capture the output directly in your script and
write it to a text file:


Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("ipconfig")
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadLine()
'Code here to write strText to a line in a text file.
Loop


-Corey

"Hoa.Hoa.Nguyen@gmail.com" wrote:

> 1) We have a script that maps and unmaps drives.
> This script is an audit script. So it is called say from Box1 to
> BoxA, BoxB, BoxZ etc...
> To find out where BoxA-BoxZ have been running backups, the script
> interrogates
> the backup logs on BoxA-BoxZ.
>
> To read the BoxA-BoxZ the script maps a drive ( V: in this instance)
>
> objNetwork.MapNetworkDrive "V:", "\\" & strComputer & "\" & "C$", ,
> strUser, strPwd
> and open to read the back up logs
> strFilePath = "V:\Program Files\Tivoli\TSM\baclient
> \dsmsched.log"
>
> When finished the drive gets disconnected/unmapped.
>
> If there multiple script jobs running concurrently, this could be a
> problem as there could be a job querying the log file as the volume
> could have been dismounted from another job.
>
> What would be the best way to read the log on a server without
> mounting the drives?
>
> 2) Another reason for mounting the drives,
> there are some windows commands like "ipconfig" we usually run the
> command, save as a text file
> errReturn = objProc.Create ("cmd.exe /c ipconfig > C:\temp
> \ipview.txt", Null, Null, intPID)
>
> Is there a better way of executing command and read the output
> directly without having to creating an extra file?
>

Re: How to read text files on remote servers without by hyk108

hyk108
Wed Mar 19 17:40:30 CDT 2008

Without the credentials using full UNC path access will be denied.
Is there a way for vbscript to provide credentials before using UNC
path?

Thanks.

Re: How to read text files on remote servers without mapping/unmapping by Pegasus

Pegasus
Wed Mar 19 19:01:04 CDT 2008


<hyk108@gmail.com> wrote in message
news:e2c56adf-0d42-4aa6-9e4a-6b0e3d677c72@d4g2000prg.googlegroups.com...
> Without the credentials using full UNC path access will be denied.
> Is there a way for vbscript to provide credentials before using UNC
> path?
>
> Thanks.

Try a batch file:
@echo off
net use \\SomePC\SomeShare /user:Hoa SomePassword
copy \\SomePC\SomeShare\SomeFile.txt d:\SomeFolder
net use \\SomePC\SomeShare /d

This represents, of course, a huge security hole. Much better
to run the script while logged on as a domain administrator.



Re: How to read text files on remote servers without mapping/unmapping drives? by Paul

Paul
Wed Mar 19 19:17:43 CDT 2008


"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message
news:%23VcmAagiIHA.5160@TK2MSFTNGP05.phx.gbl...
>
> <Hoa.Hoa.Nguyen@gmail.com> wrote in message
> news:df8d01cc-320b-46c1-a5c2-3df747201d55@m36g2000hse.googlegroups.com...
>> 1) We have a script that maps and unmaps drives.
>> This script is an audit script. So it is called say from Box1 to
>> BoxA, BoxB, BoxZ etc...
>> To find out where BoxA-BoxZ have been running backups, the script
>> interrogates
>> the backup logs on BoxA-BoxZ.
>>
>> To read the BoxA-BoxZ the script maps a drive ( V: in this
>> instance)
>>
>> objNetwork.MapNetworkDrive "V:", "\\" & strComputer & "\" & "C$", ,
>> strUser, strPwd
>> and open to read the back up logs
>> strFilePath = "V:\Program Files\Tivoli\TSM\baclient
>> \dsmsched.log"
>>
>> When finished the drive gets disconnected/unmapped.
>>
>> If there multiple script jobs running concurrently, this could be a
>> problem as there could be a job querying the log file as the volume
>> could have been dismounted from another job.
>>
>> What would be the best way to read the log on a server without
>> mounting the drives?
>>
>> 2) Another reason for mounting the drives,
>> there are some windows commands like "ipconfig" we usually run the
>> command, save as a text file
>> errReturn = objProc.Create ("cmd.exe /c ipconfig > C:\temp
>> \ipview.txt", Null, Null, intPID)
>>
>> Is there a better way of executing command and read the output
>> directly without having to creating an extra file?
>
> 1) You could use the objFSO object to open a file, using the
> UNC naming convention ("\\Server\Share\FileName.Ext").
> 2) You could use the .exec method to read the output from ipconfig
> without an intermediate file:
> Set ObjWshShell = WScript.CreateObject("WScript.Shell")
> Set ObjExec = ObjWshShell.Exec("ipconfig.exe /all")
> Do While Not ObjExec.StdOut.AtEndOfStream
> WScript.Echo ObjExec.StdOut.ReadLine 'Read a line
> Loop

I generally prefer to collect the output with a single ReadAll, as in:
' sMsg = sMsg & ObjExec.StdOut.ReadLine 'Read a line
sMsg = sMsg & ObjExec.StdOut.ReadAll 'Read everything available

Even with large output, such as a 16 megabyte directory listing, the
loop count is only one in the sample script above.

One nice thing about using the ReadLine method is that it has a fairly
flexible definition of what separates lines; it properly handles two
carriage returns and a line feed that ipconfig.exe uses as its line
separator.

-Paul Randall



Re: How to read text files on remote servers without mapping/unmapping by James

James
Thu Mar 20 07:34:08 CDT 2008

<hyk108@gmail.com> wrote in message
news:e2c56adf-0d42-4aa6-9e4a-6b0e3d677c72@d4g2000prg.googlegroups.com...
> Without the credentials using full UNC path access will be denied.
> Is there a way for vbscript to provide credentials before using UNC
> path?
>
> Thanks.

Are all of these computers on a domain? Are your scripts being run
manually or on schedule?

If the computers are on a domain and are being run on a schedule, you
can set them to run using the Task Scheduler (schtasks.exe) using a domain
account with permissions to the administrative shares on the remote
computers. Since the script will be running under an account that has
permissions to the path, you won't need to specify permissions and a UNC
connection will work.



Re: How to read text files on remote servers without by Hoa

Hoa
Fri Mar 21 17:08:28 CDT 2008

On Mar 19, 4:16=A0pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> <Hoa.Hoa.Ngu...@gmail.com> wrote in message
>
> news:df8d01cc-320b-46c1-a5c2-3df747201d55@m36g2000hse.googlegroups.com...
>
>
>
>
>
> > 1) We have a script that maps and unmaps drives.
> > This script is an audit script. =A0So it is called say from Box1 to
> > BoxA, BoxB, BoxZ etc...
> > To find out where BoxA-BoxZ have been running backups, the script
> > interrogates
> > the backup logs on BoxA-BoxZ.
>
> > To read the BoxA-BoxZ the script maps a drive ( V: in this instance)
>
> > objNetwork.MapNetworkDrive "V:", "\\" & strComputer & "\" & "C$", ,
> > strUser, strPwd
> > and open to read the back up logs
> > =A0 =A0 =A0strFilePath =3D "V:\Program Files\Tivoli\TSM\baclient
> > \dsmsched.log"
>
> > When finished the drive gets disconnected/unmapped.
>
> > If there multiple script jobs running concurrently, this could be a
> > problem as there could be a job querying the log file as the volume
> > could have been dismounted from another job.
>
> > What would be the best way to read the log on a server without
> > mounting the drives?
>
> > 2) Another reason for mounting the drives,
> > there are some windows commands like "ipconfig" we usually run the
> > command, save as a text file
> > errReturn =3D objProc.Create ("cmd.exe /c ipconfig > C:\temp
> > \ipview.txt", Null, Null, intPID)
>
> > Is there a better way of executing command and read the output
> > directly without having to creating an extra file?
>
> 1) You could use the objFSO object to open a file, using the
> =A0 =A0 =A0UNC naming convention ("\\Server\Share\FileName.Ext").
> 2) You could use the .exec method to read the output from ipconfig
> =A0 =A0 =A0without an intermediate file:
> Set ObjWshShell =3D WScript.CreateObject("WScript.Shell")
> Set ObjExec =3D ObjWshShell.Exec("ipconfig.exe /all")
> Do While Not ObjExec.StdOut.AtEndOfStream
> =A0WScript.Echo ObjExec.StdOut.ReadLine 'Read a line
> Loop- Hide quoted text -
>
> - Show quoted text -


Thank you Pegasus and Corey and everyone for their answers/suggestions
for my questions.


Re: How to read text files on remote servers without by hyk108

hyk108
Mon Mar 24 16:54:22 CDT 2008

On Mar 21, 4:08=A0pm, Hoa.Hoa.Ngu...@gmail.com wrote:
> On Mar 19, 4:16=A0pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>
>
>
>
>
> > <Hoa.Hoa.Ngu...@gmail.com> wrote in message
>
> >news:df8d01cc-320b-46c1-a5c2-3df747201d55@m36g2000hse.googlegroups.com...=

>
> > > 1) We have a script that maps and unmaps drives.
> > > This script is an audit script. =A0So it is called say from Box1 to
> > > BoxA, BoxB, BoxZ etc...
> > > To find out where BoxA-BoxZ have been running backups, the script
> > > interrogates
> > > the backup logs on BoxA-BoxZ.
>
> > > To read the BoxA-BoxZ the script maps a drive ( V: in this instance)
>
> > > objNetwork.MapNetworkDrive "V:", "\\" & strComputer & "\" & "C$", ,
> > > strUser, strPwd
> > > and open to read the back up logs
> > > =A0 =A0 =A0strFilePath =3D "V:\Program Files\Tivoli\TSM\baclient
> > > \dsmsched.log"
>
> > > When finished the drive gets disconnected/unmapped.
>
> > > If there multiple script jobs running concurrently, this could be a
> > > problem as there could be a job querying the log file as the volume
> > > could have been dismounted from another job.
>
> > > What would be the best way to read the log on a server without
> > > mounting the drives?
>
> > > 2) Another reason for mounting the drives,
> > > there are some windows commands like "ipconfig" we usually run the
> > > command, save as a text file
> > > errReturn =3D objProc.Create ("cmd.exe /c ipconfig > C:\temp
> > > \ipview.txt", Null, Null, intPID)
>
> > > Is there a better way of executing command and read the output
> > > directly without having to creating an extra file?
>
> > 1) You could use the objFSO object to open a file, using the
> > =A0 =A0 =A0UNC naming convention ("\\Server\Share\FileName.Ext").
> > 2) You could use the .exec method to read the output from ipconfig
> > =A0 =A0 =A0without an intermediate file:
> > Set ObjWshShell =3D WScript.CreateObject("WScript.Shell")
> > Set ObjExec =3D ObjWshShell.Exec("ipconfig.exe /all")
> > Do While Not ObjExec.StdOut.AtEndOfStream
> > =A0WScript.Echo ObjExec.StdOut.ReadLine 'Read a line
> > Loop- Hide quoted text -
>
> > - Show quoted text -
>
> Thank you Pegasus and Corey and everyone for their answers/suggestions
> for my questions.- Hide quoted text -
>
> - Show quoted text -

Thank you all, I was able to resolve the it this way:

Set args=3DWScript.Arguments

strComputer =3D args.Item(0)
strUser =3D args.Item(1)
strPwd =3D args.Item(2)

Set Wsh =3D WScript.CreateObject("WScript.Shell")

Wsh.run ("cmd /c net use \\" & strComputer & "\C$ /user:" & """" &
strUser & """" & " " & """" & strPwd & """")
Wsh.run ("cmd /c copy \\" & strComputer & "\C$\Temp\test.txt C:
\temp")
Wsh.run ("cmd /c net use " & strComputer & "\C$ /d")

Also, objExecObject.StdOut was very helpful.

Thanks again!