My impression is that most of the requirements you mentioned suggest some plausible use cases for Windows Script Host (WSH), which gives scripting access to a subset of the Windows API via a scripting environment. ActivePerl on Windows has an extension to support WSH if all you want to access are Windows-specific facilities. I do not have much exposure to this kind of scripting so I cannot give you any concrete code here.
for further information. A quick browse I see the Scripting.FileSystemObject that supports a "freespace" attribute, a "dateCreated" property for files. I can't find process management in this glance but probably I just overlooked it.
Afraid I cannot figure our the code that I would need to use with wsh - I have no objections to using it (assuming I dont have to install anything else)
Can anyone help?
Examples of code to help me out would be great if possible..
Const HARD_DISK = 3
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")
For Each objDisk in colDisks
Wscript.Echo "DeviceID: "& vbTab & objDisk.DeviceID
Wscript.Echo "Free Disk Space: "& vbTab & objDisk.FreeSpace
Next
usage: save as checkDiskSpace.vbs then on command line, type:
c:\> cscript checkDiskSpace.vbs
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")
For Each objProc in colProcesses
Wscript.Echo "Caption: "& vbTab & objProc.Caption
Wscript.Echo "Command Line: "& vbTab & objProc.CommandLine
Next
usage: save as checkProcess.vbs and type
c:\> cscript checkProcess.vbs
Set objFSO = CreateObject("Scripting.FileSystemObject")
myFileToCheck = "c:\test\test.txt"
If objFSO.FileExists(myFileToCheck) Then
WScript.Echo "file exists"
Else
WScript.Echo "file does not exist"
End If
Instead of echo the output to terminal can I output it to a file? If so how.
I am sure this is simple but I dont know vbs...
Can I run the cscript itsself using a perl call?
ie I have a perl script checking a few other things - can I get the perl script to execute the vbs script ?