xp c# windows服務執行外部程式的bug.....

請教..

為了測試xp下的windows服務,真的把我快搞昏頭了...
經過反覆測試,我認為應該是xp windows服務的bug..,在win7/8下都昰正常,但在xp下,主控台應用程式跟win應用程式都正常,就是windows服務不正常....xp 的windows服務光個簡單執行個 .bat 批次檔都有問題..
win8的輸入法常跳到全形,光個空白鍵就是兩個字元,也讓我花不少時間才找到這問題...
最後是win xp下windows服務執行外部程式有這bug,那我想破頭不知要如何解決了? 請高手指點..

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.IO;
using System.Net;
using System.Collections;

  
namespace SetA_
{
public partial class Service1 : ServiceBase
{
private Timer MyTimer;

public Service1()
{
InitializeComponent();
}

protected override void OnStart(string[] args)
{
MyTimer = new Timer();
MyTimer.Elapsed += new ElapsedEventHandler(MyTimer_Elapsed);
MyTimer.Interval = 10* 60 * 1000; // 10min
MyTimer.Start();
}

private void MyTimer_Elapsed(object sender, ElapsedEventArgs e)
{


Process p = Process.Start("compr.bat");
p.WaitForExit();


}

protected override void OnStop()
{
MyTimer.Stop();
MyTimer = null;
}

}
}


--------------------------
compr.bat //compr.bat 丢在 c:\windows 下

start C:\"Program Files"\WinRAR\WinRAR.exe a c:\test\vba d:\vbe\tmp\*.* 
2015-05-03 18:26 發佈
有沒有錯誤訊息??建議你把錯誤訊息記錄下來比較好除錯


還有建議
Process p = Process.Start("compr.bat");

改成
Process p = Process.Start("C:\\Windows\\compr.bat");

因為你不能保證每個執行環境,compr.bat就是指向C:\\Windows\\compr.bat

Wesley Hsu wrote:
有沒有錯誤訊息??...(恕刪)



您好:


已經可以了,因為win8的輸入都是全形,所以沒注意到...
另外建議的我記起來了...


tks.
內文搜尋
X
評分
評分
複製連結
Mobile01提醒您
您目前瀏覽的是行動版網頁
是否切換到電腦版網頁呢?