在任务计划程序下运行特定的vbs脚本时没有输出

时间:2014-03-23 13:45:53

标签: batch-file vbscript task scheduler wsh

当我运行调用cpusage.vbs的follow bat包装器时 任务计划程序启用了“运行其他用户是否已登录”选项。 我得到EMPTY作为输出,否则没关系。

这是包装器:

@echo off
SET SERVER=c:\Logs
SET TOOLOC=c:\Tools

SET datestamp=%date:~-4%%date:~-7,2%%date:~-10,2%
SET timestamp=%datestamp%%time:~0,2%%time:~3,2%%time:~6,2%
if %time:~0,2% LSS 10 SET timestamp=%datestamp%"0"%time:~0,2%%time:~3,2%%time:~6,2%


echo %timestamp% >> %SERVER%\%COMPUTERNAME%-CPU_%datestamp%.log
cscript //NoLogo %TOOLOC%\cpusage.vbs >> %SERVER%\%COMPUTERNAME%-CPU_%datestamp%.log 2>&1

可以在此处找到cpusage.vbs:http://www.pastebin.ca/2677241

谢谢,

2 个答案:

答案 0 :(得分:0)

对于CPU

wmic path Win32_PerfFormattedData_PerfOs_Processor get /format:list
wmic path Win32_PerfFormattedData_PerfOs_Processor get PercentProcessorTime /format:list

对于您的磁盘报告

wmic logicaldisk get FreeSpace,size,mediatype /format:list

为了你的记忆(我无法找到你的剧本,所以我只是猜测你正在使用的是什么)

wmic os get TotalVisibleMemorySize, TotalVirtualMemorySize, TotalSwapSpaceSize, SizeStoredInPagingFiles, MaxProcessMemorySize, FreePhysical Memory, FreeSpaceInPagingFiles, FreeVirtualMemory /format:hform >mem.html&start "" mem.html

答案 1 :(得分:-2)

尝试启用延迟展开并使用FOR /F

setlocal enabledelayedexpansion
FOR /F "tokens=*" %%a in ('cscript //NoLogo "!TOOLOC!\cpusage.vbs" 2^>^&1') do (echo/%%a >> "!SERVER!\!COMPUTERNAME!-CPU_!datestamp!.log")