簡體   English   中英

在XP上將Powershell 2.0腳本作為計划任務

[英]Powershell 2.0 script as scheduled task on XP

我有一個簡單的問題,包括XP,PowerShell和計划任務。我有一個工作腳本,該腳本在Win7上使用PowerShell 2.0和計划任務,我只想在Windows XP上做同樣的事情。我安裝了必需的框架,並且腳本已准備就緒winxp,但我只是無法使計划的任務正常工作。我給你我在win7上使用的安裝棒自動添加所需的計划任務,並希望學習如何在winxp上計划任務。

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"

基本上,我需要在win xp計划任務中進行與上述(win7)相同的安裝.Powershell腳本位於計算機下方的目錄中。

C:\\ Documents and Settings \\ Administrator \\ Desktop \\ PowerIdleV3 \\ power_script.ps1

提前致謝!

編輯:我找到了解決方案:

1)添加一個自定義程序,選擇C:\\ WINDOWS \\ system32 \\ WindowsPowerShell \\ v1.0 \\ powershell.exe

2)然后將程序行更改為C:\\ WINDOWS \\ system32 \\ WindowsPowerShell \\ v1.0 \\ powershell.exe -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File C:\\ PowerIdleV3 \\ power_script.ps1

我正在使用此語法來運行計划的* .ps1文件C:\\ WINDOWS \\ system32 \\ WindowsPowerShell \\ v1.0 \\ powershell.exe -command。\\ automatedemail1.ps1

AUTOMATEDEMAIL1.PS1
$email="?@?.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 and Settings \\ jyoung \\ testmail1.bat”

TESTMAIL1.BAT powershell.exe-命令。\\ automatedemail1.ps1

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM