I cant get it to log to the text file. I had it before and then i broke it into pieces and put it in a nice order so it can be followed. Now it will not work right and i know its because i reordered everything. At work i do not ahve a script writer im just using notepad and im really not that great. This is what i have so far. Also i would like to add that the file it dumps to is there a way that i can have it dump on who evers desktop who happens to be signed in while using it.
Dim objFileSystem, objOutputFile
Dim strOutputFile
strOutputFile = "c:\output.txt"
Set objFileSystem = CreateObject("Scripting.fileSystemObject")
ForAppending = 8
Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, ForAppending, True)
RemoteMachine = InputBox("Enter the Machine Name or IP Address you wish to Query:")
Set objWMIService = GetObject("winmgmts:\\" & RemoteMachine)
Set objLocaldrive = objWMIService.Get ("Win32_LogicalDisk.DeviceID='c:'")
Set objSWbemServices = Getobject("winmgmts:\\" & RemoteMachine)
Set colServices = objSWbemServices.InstancesOf("Win32_NetworkLoginProfile")
For Each objService in colServices
STRNAME = objService.Name
Next
Y = LEN(STRNAME)
X = Y - 8
STRUNAME = MID(STRNAME, 10, X)
Const CONVERSION_FACTOR = 1048576
Const WARNING_THRESHOLD = 500
FreeMegaBytes = objLocaldrive.Freespace / CONVERSION_FACTOR
If RemoteMachine = "" Then
MsgBox ("You Must Enter A Machine Name or IP Address.") : WScript.quit
Else
End If
If FreeMegaBytes < WARNING_THRESHOLD Then
Wscript.Echo "C: is low on disk space."
ELSE
End If
Set objLocaldrive = objWMIService.Get ("Win32_LogicalDisk.DeviceID='D:'")
FreeMegaBytes1 = objLocaldrive.Freespace / CONVERSION_FACTOR
If RemoteMachine = "" Then
Else
End If
If FreeMegaBytes1 < WARNING_THRESHOLD1 Then
Wscript.Echo "D: is low on disk space."
ELSE
End If
On Error Resume Next
Set WshShell = WScript.CreateObject("WScript.Shell")
Set CommandLine = CreateObject("WScript.Shell")
Set filesys = CreateObject("Scripting.FileSystemObject")
GetObject("winmgmts:\\" & RemoteMachine & "\root\CIMV2")
Set colOperatingSystems=objWMIService.ExecQuery _
("Select * From Win32_PerfFormattedData_PerfOS_System")
For Each objOS in colOperatingSystems
intSystemUptime=Int(objOS.SystemUpTime)
TimedAt=FormatDateTime(Date(),2) &", " &FormatDateTime(Time(),4)
Next
Function UpTime(S)
M=S\60 : S=S mod 60 : H=M\60 : M=M mod 60 : D=H\24
UpTime=D &" Days, " & H MOD 24 &" Hours, " &M &" Minutes"
End Function
Set objWMIService = GetObject("winmgmts:\\" & RemoteMachine & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'")
For Each objItem in colItems
next
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SYSTEM\ControlSet001\Control\Session Manager\Memory Management"
iValues = Array("string1", "string2")
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" & _
RemoteMachine & "\root\default:StdRegProv")
MultValueName = "PagingFiles"
oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,_
MultValueName,iValues
For Each strValue In iValues
Next
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
RemoteMachine & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\ControlSet001\Services\Tcpip\Parameters"
strvaluename = "searchlist"
oReg.GetStringValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,svalue
ArrComputer = ","
ArrServices = Array("Smart Card", "ActivClient Middleware Service")
For Each RemoteMachine In ArrComputer
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objItem in colItems
For Each Service In ArrServices
If Service = objItem.DisplayName Then
End If
Next
Next
Next
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(RemoteMachine,"root\CIMV2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkConnection",,48)
For Each objItem in colItems
StrDrivePath = StrDrivePath & "LocalName: " & objItem.LocalName & VbCrLf
StrDrivePath = StrDrivePath & "RemotePath: " & objItem.RemotePath & VbCrLf
CommandLine.run "C:\MAP_DRIVES.BAT " & UCASE(objItem.LocalName) & " " & UCASE(objItem.RemotePath) & " " & UCASE(StrPROPATH)
Next
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=Impersonate}!\\" & RemoteMachine & "\root\cimv2")
Set ColInstalledPrinters = objWMIService.ExecQuery ("Select * From Win32_Printer")
For Each objPrinter in ColInstalledPrinters
Select Case objPrinter.PrinterStatus
Case 1
StrPrinterStatus = "Other"
Case 2
StrPrinterStatus = "Unknown"
Case 3
StrPrinterStatus = "Idle"
Case 4
StrPrinterStatus = "Printing"
Case 5
StrPrinterStatus = "Warmup"
End Select
StrPrintStatus = StrPrintStatus & "Name: " & objPrinter.Name & VbCrLf
StrPrintStatus = StrPrintStatus & "Printer Status: " & VbCrLf
StrPrintStatus = StrPrintStatus & VbCrLf
next
On Error Resume Next
If RemoteMachine = "" Then
MsgBox ("You Must Enter in a Machine Name or IP Address.") : WScript.quit
Else
Set objSWbemServices = GetObject("winmgmts:\\" & RemoteMachine)
Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_LogicalMemoryConfiguration")
wscript.echo "RUNNING NOW"
For Each objSWbemObject in colSWbemObjectSet
objOutputFile.WriteLine date & " " & Time & VbCrLf & _
STRUNAME & VbCrLf & "Hard Drive Space" & VbCrLf & _
"Megabytes of Free Disk Space on c:\ " & Int(FreeMegaBytes) & VbCrLf & _
"Megabytes of Free Disk Space on D:\ " & Int(FreeMegaBytes1) & VBCrLF & VBCrLF & _
"Last Restarted" & vbCrLf & UpTime(intSystemUptime) & VBCrLF & VBCrLF & _
"CPU Usage" & VBCrLF & objItem.PercentProcessorTime & " %" & VBCrLF & VBCrLF & _
"Page File Set To" & VBCrLF & strValue & VBCrLF & VBCrLF & _
"DNS Search Order: " & VBCrLF & svalue & VBCrLF & VBCrLF & _
"DisplayName: " & objItem.DisplayName & " State: " & objItem.State & VbCrLf & VbCrLf & _
"NETWORK DRIVES CURRENTLY MAPPED: " & VbCrLf & VbCrLf & StrDrivePath & VbCrLf & VbCrLf & _
"PRINTERS CURRENTLY MAPPED: " & VbCrLf & VbCrLf & StrPrintStatus & VbCrLf & VbCrLf
next
end if
objOutputFile.Close
Set objFileSystem = Nothing
WScript.Quit(0)
Dim objFileSystem, objOutputFile
Dim strOutputFile
strOutputFile = "c:\output.txt"
Set objFileSystem = CreateObject("Scripting.fileSystemObject")
ForAppending = 8
Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, ForAppending, True)
RemoteMachine = InputBox("Enter the Machine Name or IP Address you wish to Query:")
Set objWMIService = GetObject("winmgmts:\\" & RemoteMachine)
Set objLocaldrive = objWMIService.Get ("Win32_LogicalDisk.DeviceID='c:'")
Set objSWbemServices = Getobject("winmgmts:\\" & RemoteMachine)
Set colServices = objSWbemServices.InstancesOf("Win32_NetworkLoginProfile")
For Each objService in colServices
STRNAME = objService.Name
Next
Y = LEN(STRNAME)
X = Y - 8
STRUNAME = MID(STRNAME, 10, X)
Const CONVERSION_FACTOR = 1048576
Const WARNING_THRESHOLD = 500
FreeMegaBytes = objLocaldrive.Freespace / CONVERSION_FACTOR
If RemoteMachine = "" Then
MsgBox ("You Must Enter A Machine Name or IP Address.") : WScript.quit
Else
End If
If FreeMegaBytes < WARNING_THRESHOLD Then
Wscript.Echo "C: is low on disk space."
ELSE
End If
Set objLocaldrive = objWMIService.Get ("Win32_LogicalDisk.DeviceID='D:'")
FreeMegaBytes1 = objLocaldrive.Freespace / CONVERSION_FACTOR
If RemoteMachine = "" Then
Else
End If
If FreeMegaBytes1 < WARNING_THRESHOLD1 Then
Wscript.Echo "D: is low on disk space."
ELSE
End If
On Error Resume Next
Set WshShell = WScript.CreateObject("WScript.Shell")
Set CommandLine = CreateObject("WScript.Shell")
Set filesys = CreateObject("Scripting.FileSystemObject")
GetObject("winmgmts:\\" & RemoteMachine & "\root\CIMV2")
Set colOperatingSystems=objWMIService.ExecQuery _
("Select * From Win32_PerfFormattedData_PerfOS_System")
For Each objOS in colOperatingSystems
intSystemUptime=Int(objOS.SystemUpTime)
TimedAt=FormatDateTime(Date(),2) &", " &FormatDateTime(Time(),4)
Next
Function UpTime(S)
M=S\60 : S=S mod 60 : H=M\60 : M=M mod 60 : D=H\24
UpTime=D &" Days, " & H MOD 24 &" Hours, " &M &" Minutes"
End Function
Set objWMIService = GetObject("winmgmts:\\" & RemoteMachine & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'")
For Each objItem in colItems
next
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SYSTEM\ControlSet001\Control\Session Manager\Memory Management"
iValues = Array("string1", "string2")
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" & _
RemoteMachine & "\root\default:StdRegProv")
MultValueName = "PagingFiles"
oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,_
MultValueName,iValues
For Each strValue In iValues
Next
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
RemoteMachine & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\ControlSet001\Services\Tcpip\Parameters"
strvaluename = "searchlist"
oReg.GetStringValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,svalue
ArrComputer = ","
ArrServices = Array("Smart Card", "ActivClient Middleware Service")
For Each RemoteMachine In ArrComputer
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objItem in colItems
For Each Service In ArrServices
If Service = objItem.DisplayName Then
End If
Next
Next
Next
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(RemoteMachine,"root\CIMV2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkConnection",,48)
For Each objItem in colItems
StrDrivePath = StrDrivePath & "LocalName: " & objItem.LocalName & VbCrLf
StrDrivePath = StrDrivePath & "RemotePath: " & objItem.RemotePath & VbCrLf
CommandLine.run "C:\MAP_DRIVES.BAT " & UCASE(objItem.LocalName) & " " & UCASE(objItem.RemotePath) & " " & UCASE(StrPROPATH)
Next
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=Impersonate}!\\" & RemoteMachine & "\root\cimv2")
Set ColInstalledPrinters = objWMIService.ExecQuery ("Select * From Win32_Printer")
For Each objPrinter in ColInstalledPrinters
Select Case objPrinter.PrinterStatus
Case 1
StrPrinterStatus = "Other"
Case 2
StrPrinterStatus = "Unknown"
Case 3
StrPrinterStatus = "Idle"
Case 4
StrPrinterStatus = "Printing"
Case 5
StrPrinterStatus = "Warmup"
End Select
StrPrintStatus = StrPrintStatus & "Name: " & objPrinter.Name & VbCrLf
StrPrintStatus = StrPrintStatus & "Printer Status: " & VbCrLf
StrPrintStatus = StrPrintStatus & VbCrLf
next
On Error Resume Next
If RemoteMachine = "" Then
MsgBox ("You Must Enter in a Machine Name or IP Address.") : WScript.quit
Else
Set objSWbemServices = GetObject("winmgmts:\\" & RemoteMachine)
Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_LogicalMemoryConfiguration")
wscript.echo "RUNNING NOW"
For Each objSWbemObject in colSWbemObjectSet
objOutputFile.WriteLine date & " " & Time & VbCrLf & _
STRUNAME & VbCrLf & "Hard Drive Space" & VbCrLf & _
"Megabytes of Free Disk Space on c:\ " & Int(FreeMegaBytes) & VbCrLf & _
"Megabytes of Free Disk Space on D:\ " & Int(FreeMegaBytes1) & VBCrLF & VBCrLF & _
"Last Restarted" & vbCrLf & UpTime(intSystemUptime) & VBCrLF & VBCrLF & _
"CPU Usage" & VBCrLF & objItem.PercentProcessorTime & " %" & VBCrLF & VBCrLF & _
"Page File Set To" & VBCrLF & strValue & VBCrLF & VBCrLF & _
"DNS Search Order: " & VBCrLF & svalue & VBCrLF & VBCrLF & _
"DisplayName: " & objItem.DisplayName & " State: " & objItem.State & VbCrLf & VbCrLf & _
"NETWORK DRIVES CURRENTLY MAPPED: " & VbCrLf & VbCrLf & StrDrivePath & VbCrLf & VbCrLf & _
"PRINTERS CURRENTLY MAPPED: " & VbCrLf & VbCrLf & StrPrintStatus & VbCrLf & VbCrLf
next
end if
objOutputFile.Close
Set objFileSystem = Nothing
WScript.Quit(0)