scripting output
i need to output this to file please assist
many thanks
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Environment")
For Each objItem in colItems
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "System Variable: " & objItem.SystemVariable
Wscript.Echo "User Name: " & objItem.UserName
Wscript.Echo "Variable Value: " & objItem.VariableValue
Next
many thanks
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Environment")
For Each objItem in colItems
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "System Variable: " & objItem.SystemVariable
Wscript.Echo "User Name: " & objItem.UserName
Wscript.Echo "Variable Value: " & objItem.VariableValue
Next
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
spartacus
17 years ago
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const OutputFile = "C:\Temp\output.txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set txt = oFSO.OpenTextFile(OutputFile, ForWriting, True)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Environment")
For Each objItem in colItems
txt.Writeline "Description: " & objItem.Description
txt.Writeline "Name: " & objItem.Name
txt.Writeline "System Variable: " & objItem.SystemVariable
txt.Writeline "User Name: " & objItem.UserName
txt.Writeline "Variable Value: " & objItem.VariableValue
Next
txt.Close
Const ForWriting = 2
Const ForAppending = 8
Const OutputFile = "C:\Temp\output.txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set txt = oFSO.OpenTextFile(OutputFile, ForWriting, True)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Environment")
For Each objItem in colItems
txt.Writeline "Description: " & objItem.Description
txt.Writeline "Name: " & objItem.Name
txt.Writeline "System Variable: " & objItem.SystemVariable
txt.Writeline "User Name: " & objItem.UserName
txt.Writeline "Variable Value: " & objItem.VariableValue
Next
txt.Close
Posted by:
rudi
17 years ago
Posted by:
spartacus
17 years ago
This should hopefully get you started :
Regards,
Spartacus
Const FolderToSearch = "C:\Lotus\Notes\data"
Const OutputFile = "C:\Temp\results.txt"
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim oFSO
Dim oFolder,oFiles
Dim text,ext
'Instantiate the FileSystem Object
set oFSO = CreateObject("Scripting.FileSystemObject")
' Check if folder to be searched exists at all and, if not exit gracefully
if oFSO.FolderExists(FolderToSearch) then
' Search Folder was found, so open the report file
Set txt = oFSO.OpenTextFile(OutputFile, ForWriting, True)
set oFolder = OFSO.GetFolder(FolderToSearch)
' Get collection of all the files in the folder to be searched
set oFiles = ofolder.Files
for each file in oFiles
' Get hold of the file extension and, if one of the ones we are looking for, log the filename to the report file
ext = oFSO.GetExtensionName(file.name)
ext = ucase(ext)
if ext = "NSF" OR ext = "NDK" OR ext = "ID" then
txt.writeline file.name
end if
next
txt.close
end if
set oFSO = Nothing
Regards,
Spartacus
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.