$aTargets = FileIO('c:\scripts\hosts.txt', 'R')
For Each $Host in $aTargets
; run code to query each $Host value
If Ping($Host)
$HostPath = '\\' + $Host + 'C$\users'
'Processing ' $HostPath ? ; for debugging or status reporting
; run any necessary command using $HostPath to reference the target path
$logFile = @ScriptDir+"\Profile Sizes.ini"
$profiles = DirList($HostPath)
For Each $profile in $profiles
If Right($profile, 1) = "\"
$profilename = Split($profile, "\")
$profilename = $profilename[UBound($profilename)-1]
$nul = WriteProfileString($logfile, @WkSta+"\"+$profilename, "Desktop", fnGetFolderProp($profile+"Desktop","Size"))
$nul = WriteProfileString($logfile, @WkSta+"\"+$profilename, "Documents", fnGetFolderProp($profile+"My Documents","Size"))
Endif
Next
Function fnGetFolderProp($sFldr,$sProp)
Dim $objFSO, $objFldr, $nul
$objFSO = CreateObject("Scripting.FileSystemObject")
If Not VarType($objFSO)=9 Exit 1 EndIf
$objFldr = $objFSO.GetFolder($sFldr)
If Not VarType($objFldr)=9 Exit 3 EndIf
$nul=Execute("$$fnGetFolderProp = $$objFldr."+$sProp)
If VarType($fnGetFolderProp)=0 Exit 87 EndIf
EndFunction
Function dirlist($dirname, optional $options)
dim $filename, $counter, $filepath, $mask
dim $list, $sublist, $subcounter
$counter=-1
$dirname=trim($dirname)
if $dirname=''
$dirname=@CURDIR
endif
if right($dirname,1)='\'
$dirname=left($dirname,len($dirname)-1)
endif
EndIf
Next
;FUNCTION Ping()
;
;AUTHOR Jochen Polster (jochenDOTpolsterATgmxDOTnet)
;
;VERSION HISTORY 1.0 - 11/24/2001 Initial Release
; 1.1 - 11/11/2004 Fixed problems regarding spaces in folder names
; of script directory (thanks to Alistair)
; 1.2 - 12/07/2004 Fixed for NoVarsInStrings and Explicit on
;
;ACTION Pings the Computer specified, or returns its ip address (Wins Resolved)
;
;SYNTAX Ping(Computer,GetIP,[LoopCount],[Timeout])
;
;PARAMETERS Computer (Required)
; - String value representing the Computer to ping
;
; GetIp (Required)
; - If specified (1), the function will return the ip-address
; of specified Computer rather than pinging it ...
; Has to be 0 if you want to check for reply !
;
; LoopCount (Optional but useful !)
; - Integer value representing the number of times
; the Computer shall be pinged
;
; Timeout (Optional)
; - if ommited the Computer gets pinged with the default
; timeout (1s) and default retries (4)
;
;REMARKS If there is a reply the function will return immediately with 1
; so it could be faster not specifiying a timeout.
;
;RETURNS 0 - No reply
; 1 - Ping reply
; Optional - ip address of specified Computer
;
;DEPENDENCIES None
;
;EXAMPLES call "path\Ping.udf"
; if Ping("www.microsoft.com",0,12,5000) ;pings for max. 60 seconds
; run "%ComSpec% /c start www.microsoft.com"
; else
; 'Site isn't available ' ?
; endif
; if Ping("www.microsoft.com",0,15) ;pings also for max. 60 seconds
; run "%ComSpec% /c start www.microsoft.com"
; else
; 'Site isn't available ' ?
; endif
; $ip = Ping("www.microsoft.com",1)
; $ip ?
function Ping($Computer,$GetIP,optional $LoopCount,optional $TimeOut)
if $GetIP
dim $ip, $ipfile, $
$ipfile = @scriptdir + '\ip.txt'
shell '%Comspec% /q /e:1024 /c for /F "tokens=2 delims=[]" %%i IN ('+ chr(39)
+ '"ping ' + $Computer + ' -n 1 | find "]""' + chr(39) + ') do echo %%i >"' + $ipfile + '"'
$ = open(10,$ipfile,2) $ip = readline(10) $ = close(10) del $ipfile
if $ip
$Ping = $ip
else
$Ping = 'Bad IP address ' + $Computer + '!'
endif
exit 0
else
if $TimeOut
for $c = 0 to $LoopCount
shell '%Comspec% /C ping ' + $Computer + ' -n 1 -w ' + $TimeOut + ' | find /C "TTL=" > nul'
if @error = 0
$Ping = 1
exit 0
endif
next
else
for $c = 0 to $LoopCount
shell '%Comspec% /C ping ' + $Computer + ' | find /C "TTL=" > nul'
if @error = 0
$Ping = 1
exit 0
endif
next
endif
$Ping = 0
endif
endfunction