2013-10-19 110 views
1

我有一个简单的问题,包括XP,PowerShell和计划任务。我有一个工作脚本,使用PowerShell 2.0和计划任务在Win7上,我想要的是在Windows XP 。我安装了必需的框架,并且脚本已经准备好在winxp上,但是我不能让计划任务工作。我给你安装了我在win7上使用的bat,以自动添加所需的计划任务,并期望学习如何安排它同样在winxp上。Powershell 2.0脚本作为XP上的计划任务

schtasks /delete /tn "PowerIdle" /F 
schtasks /delete /tn "PowerIdleKill" /F 
schtasks /delete /tn "PowerIdleSleep" /F 
schtasks /create /tn "PowerIdle" /tr "powershell -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File \"%~dp0power_script.ps1\"" /sc minute /mo 30 /st 00:00 
schtasks /run /tn "PowerIdle" 

基本上我需要同上面安装(WIN7)在Win XP的计划tasks.Powershell脚本位于在我的电脑下面的目录。

C:\ Documents和Settings \管理员\桌面\ PowerIdleV3 \ power_script.ps1提前

谢谢!

编辑: 我找到了解决方案:

1)添加自定义程序,选择 C:\窗口\ system32 \ WindowsPowerShell \ V1.0 \ powershell.exe

2)然后程序行改变至低于 C:\窗口\ system32 \ WindowsPowerShell \ V1.0 \ powershell.exe -nonInteractive -WindowStyle隐藏-ExecutionPolicy旁路-File C:\ PowerIdleV3 \ power_script.ps1

+0

4多年以后,感谢您添加您的soluti上。 – khaverim

回答

0

我使用这个语法运行计划*的.ps1文件 C:\ WINDOWS \ SYSTEM32 \ WindowsPowerShell \ V1.0 \ powershell.exe -command \ automatedemail1.ps1

AUTOMATEDEMAIL1.PS1 
$email="[email protected]?.com" 
$subject="Lunch" 
$body="back in an hour $(get-date)” 

Send-MailMessage -from $email -to $email -subject $subject -body $body -smtpServer esdsmtp –bodyashtml 

这句法运行bat文件,其轮流执行PS作业 “C:\ Documents和Settings \ jyoung \ testmail1.bat”。

TESTMAIL1.BAT powershell.exe -command \ automatedemail1.ps1

AUTOMATEDEMAIL1.PS1 
$email="[email protected]?.com" 
$subject="Lunch" 
$body="back in an hour $(get-date)” 

Send-MailMessage -from $email -to $email -subject $subject -body $body -smtpServer  ???smtp –bodyashtml 
相关问题