Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Script to display page file

Reply
 
Old 08-06-2009   #1 (permalink)


Vista Business
 
 

Script to display page file

Group,
I have been racking my brain on this one.. I just can not seem to get it to work. I want to run a script that will display or write the information to a text file for a list of computers in a txt file. Here is what I have so far...

for /f %%i in (c:\temp\computers.txt) do cscript c:\temp\pagefile.vbs %%i >> c:\temp\text.txt

VBS Script-
Function GetPageFile(strComputer)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPageFiles = objWMIService.ExecQuery _
("Select * from Win32_PageFile")
For each objPageFile in colPageFiles
Wscript.Echo "CreationDate: " & vbTab & objPageFile.CreationDate
Wscript.Echo "Description: " & vbTab & objPageFile.Description
Wscript.Echo "Drive: " & vbTab & objPageFile.Drive
Wscript.Echo "FileName: " & vbTab & objPageFile.FileName
Wscript.Echo "FileSize: " & vbTab & objPageFile.FileSize
Wscript.Echo "InitialSize: " & vbTab & objPageFile.InitialSize
Wscript.Echo "InstallDate: " & vbTab & objPageFile.InstallDate
Wscript.Echo "MaximumSize: " & vbTab & objPageFile.MaximumSize
Wscript.Echo "Name: " & vbTab & objPageFile.Name
Wscript.Echo "Path: " & vbTab & objPageFile.Path
Next
End Function

Any help would be most appricated.
Thanks

My System SpecsSystem Spec
Old 08-06-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: Script to display page file


"verylost" <guest@xxxxxx-email.com> wrote in message
news:5dadd10c29a3b16ee5727300fc097719@xxxxxx-gateway.com...
Quote:

>
> Group,
> I have been racking my brain on this one.. I just can not seem to get
> it to work. I want to run a script that will display or write the
> information to a text file for a list of computers in a txt file. Here
> is what I have so far...
>
> for /f %%i in (c:\temp\computers.txt) do cscript c:\temp\pagefile.vbs
> %%i >> c:\temp\text.txt
>
> VBS Script-
> Function GetPageFile(strComputer)
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer &
> "\root\cimv2")
> Set colPageFiles = objWMIService.ExecQuery _
> ("Select * from Win32_PageFile")
> For each objPageFile in colPageFiles
> Wscript.Echo "CreationDate: " & vbTab & objPageFile.CreationDate
> Wscript.Echo "Description: " & vbTab & objPageFile.Description
> Wscript.Echo "Drive: " & vbTab & objPageFile.Drive
> Wscript.Echo "FileName: " & vbTab & objPageFile.FileName
> Wscript.Echo "FileSize: " & vbTab & objPageFile.FileSize
> Wscript.Echo "InitialSize: " & vbTab & objPageFile.InitialSize
> Wscript.Echo "InstallDate: " & vbTab & objPageFile.InstallDate
> Wscript.Echo "MaximumSize: " & vbTab & objPageFile.MaximumSize
> Wscript.Echo "Name: " & vbTab & objPageFile.Name
> Wscript.Echo "Path: " & vbTab & objPageFile.Path
> Next
> End Function
>
> Any help would be most appricated.
> Thanks
> --
> verylost
Your GetPageFile function works fine but it is not clear what you're having
a problem with. Can't read the list of PCs from a text file? Don't know how
to write the result directly into a text file?

In general you should aim for a uniform environment. Since you need a VB
Script file to extract the paging file details, you might as well use this
same VB Script file to process the list of computers and to write the result
into a text file instead of using a mixed batch/VB Script technique. Which
of the functions are you unfamiliar with - reading the PC list or writing
the result to a file? Both require the File System Object and both functions
are described in detail, with examples, in the helpfile script56.chm which
you can download from the Microsoft site.


My System SpecsSystem Spec
Old 08-06-2009   #3 (permalink)
Tom Lavedas


 
 

Re: Script to display page file

On Aug 6, 3:15*pm, verylost <gu...@xxxxxx-email.com> wrote:
Quote:

> Group,
> I have been racking my brain on this one.. I just can not seem to get
> it to work. *I want to run a script that will display or write the
> information to a text file for a list of computers in a txt file. *Here
> is what I have so far...
>
> for /f %%i in (c:\temp\computers.txt) do cscript c:\temp\pagefile.vbs
> %%i >> c:\temp\text.txt
>
> VBS Script-
> Function GetPageFile(strComputer)
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer &
> "\root\cimv2")
> Set colPageFiles = objWMIService.ExecQuery _
> ("Select * from Win32_PageFile")
> For each objPageFile in colPageFiles
> Wscript.Echo "CreationDate: " & vbTab & *objPageFile.CreationDate
> Wscript.Echo "Description: " & vbTab & *objPageFile.Description
> Wscript.Echo "Drive: " & vbTab & *objPageFile.Drive * * * *
> Wscript.Echo "FileName: " & vbTab & *objPageFile.FileName *
> Wscript.Echo "FileSize: " & vbTab & *objPageFile.FileSize *
> Wscript.Echo "InitialSize: " & vbTab & *objPageFile.InitialSize
> Wscript.Echo "InstallDate: " & vbTab & *objPageFile.InstallDate
> Wscript.Echo "MaximumSize: " & vbTab & *objPageFile.MaximumSize
> Wscript.Echo "Name: " & vbTab & *objPageFile.Name *
> Wscript.Echo "Path: " & vbTab & *objPageFile.Path *
> Next
> End Function
>
> Any help would be most appricated.
> Thanks
>
> --
> verylost
There are two simple problems: You're not passing in the computer
names to the script and the script has no line to call the function
(so it doesn't get executed).

With the batch construct you have chosen to read the computer names,
you just need to add the following to your script ...

if wsh.arguments.count > 0 then
GetPageFile wsh.arguments(0)
end if

Function GetPageFile(strComputer)
....

Or you can read the file's contents directly in the script using
something like this ...

if wsh.arguments.count > 0 then
with createobject("scripting.filesystemobject")
if .fileexists(wsh.arguments(0)) then
sTemp = .opentextfile(wsh.arguments(0), 1).readAll
for each strcomp in split(sTemp, vbnewline)
wsh.echo "-------", strcomp, "-------"
GetPageFile strcomp
wsh.echo ""
next
else
wsh.echo "Cannot find file:", wsh.arguments(0)
end if
end with
wsh.echo "No file name provided."
end if
wsh.echo "DONE"

Function GetPageFile(strComputer)
....

Then this script could be called without the FOR statement like
this...

cscript c:\temp\pagefile.vbs c:\temp\computers.txt > c:\temp
\text.txt

BTW, the concepts are valid, but I didn't test the code. Hopefully,
the syntax is perfect, but no guarantees.

Tom Lavedas
**********
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Web Page display how can I Fix it Network & Sharing
problem passing args to script 'There is no script engine for file extenstion' VB Script
read and display .doc file on web page using asp.net .NET General
IE 7 can not display the page!? Vista General
Call Powershell script from ASP.NET page? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46