为什么 vbs msgbox 不能与普通用户的任务调度程序一起使用? [英] Why vbs msgbox wont work with task scheduler for normal users?

查看:16
本文介绍了为什么 vbs msgbox 不能与普通用户的任务调度程序一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 vbscript 来计算文件夹中文件/子文件夹的数量,如果数量大于 5,它会向用户弹出一条消息.我可以在管理员或普通用户帐户下手动运行此脚本,但是在我以管理员身份在任务计划程序中安排它后,它显示任务正在运行,[任务已启动] [操作已启动] [已创建任务进程] 但它永远不会结束,我从未看到在用户帐户下弹出消息框.有什么问题吗?

I have a simple vbscript that count the number of files/subfolders in a folder, if the number greater than 5, it will pop up a message to user. I can run this script manually under admin or normal user account, but after I scheduled it in task scheduler as admin, it shows task running, [task started] [action started] [created task process] but it never ends and I never see the message box pops up under user accounts. Is there anything wrong?

代码:

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

推荐答案

尝试将您的程序/脚本设为 c:\windows\syswow64\cscript.exe 或什至 c:\windows\system32\cscript.exe,然后将参数为 c:\path_to_your_vbs\your.vbs

Try your program/script to be c:\windows\syswow64\cscript.exe or even c:\windows\system32\cscript.exe and then have the argument be c:\path_to_your_vbs\your.vbs

这篇关于为什么 vbs msgbox 不能与普通用户的任务调度程序一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆