我有一个简单的vbscript来计算文件夹中的文件/子文件夹的数量,如果数量大于5,它会弹出一条消息给用户。我可以在管理员或普通用户帐户下手动运行此脚本,但在我作为管理员在任务计划程序中安排它之后,它显示任务正在运行,[任务已启动] [已启动操作] [创建任务流程]但它永远不会结束,我从未见过用户帐户下弹出消息框。有什么不对吗?
代码:
Set filesys = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("Shell.Application")
Set RTMFolder = filesys.GetFolder("C:\work\RTM")
Set PMFolder = filesys.GetFolder("C:\work\Powermill")
Set RTMFiles = RTMFolder.Files
Set PMFiles = PMFolder.SubFolders
NumberOfRTM = RTMFiles.Count
NumberofPM = PMFiles.Count
'Wscript.echo NumberOfRTM
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
If NumberOfRTM >= 5 Then
msgbox "Dear user on " & strComputerName & vbcrlf & " " & vbcrlf & "There are more than 5 RTM files saved on C:\WORK\RTM folder, Please move them to K drive.", &h51000, "Clean up C:\work\RTM"
shell.Open "C:\WORK\RTM"
End If
If NumberofPM >= 5 Then
msgbox "Dear user on " & strComputerName & vbcrlf & " " & vbcrlf & "There are more than 5 Powermill files saved on C:\WORK\Powermill folder, Please Clean it up.", &h51000, "Clean up C:\work\Powermill"
shell.Open "C:\WORK\Powermill"
End If
'Release memory
Set RTMFolder = Nothing
Set PMFolder = Nothing
Set RTMFiles = Nothing
Set PMFiles = Nothing
答案 0 :(得分:1)
尝试将您的程序/脚本设置为c:\ windows \ syswow64 \ cscript.exe,甚至是c:\ windows \ system32 \ cscript.exe,然后将参数设置为c:\ path_to_your_vbs \ your.vbs