2013-10-19 94 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 
相關問題