[英]How can I uninstall or delete Windows XP Sp3 Games using C# or free XP tools?
我實際上可以刪除這些文件,但系統幾乎會立即恢復它們。 我在使用 sysocmgr.exe 從系統中刪除游戲方面沒有成功,我想通過代碼來完成(如果我手動運行它,我可以讓 sysocmgr.exe 運行並刪除游戲,但它不適用於我登錄腳本 - 它被執行並坐在那里。如果我關閉,文件不會被刪除,但如果我打開任務管理器並結束任務,文件會被刪除)......
我的卸載批處理文件如下所示:
copy sysoc.txt "%windir%\temp\sysoc.txt" /y
sysocmgr /i:"%windir%\inf\sysoc.inf" /u:"%windir%\temp\sysoc.txt" /q /r
sysoc.txt 看起來像:
[Components]
pinball = off
Solitaire = off
freecell = off
hearts = off
minesweeper = off
spider = off
zonegames = off
有人有什么建議嗎???
您可以嘗試使用 PowerShell 腳本刪除程序(不確定是否可以刪除 XP 游戲,因為它們是 Windows 組件的一部分,但值得一試): 如何使用 PowerShell 卸載應用程序?
另外,找到了這個關於刪除游戲的工具: http://www.systemtools.com/board/Forum8/HTML/000065.html
另外,請注意登錄腳本在登錄用戶的安全上下文中運行,因此如果他們不是管理員,這幾乎肯定會失敗。 啟動腳本可能更成功。
這就是我讓它工作的方式(這是作為“SYSTEM”執行的):
using System;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
namespace XPGameRemoval
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
string WinDir = Environment.GetEnvironmentVariable("WinDir");
FileStream cStream = new FileStream(
WinDir + "\\Temp\\SysOC.txt",
FileMode.Create,
FileAccess.ReadWrite,
FileShare.ReadWrite);
StreamWriter cWriter = new StreamWriter(cStream);
cWriter.WriteLine("[Components]");
cWriter.WriteLine("pinball = off");
cWriter.WriteLine("Solitaire = off");
cWriter.WriteLine("freecell = off");
cWriter.WriteLine("hearts = off");
cWriter.WriteLine("minesweeper = off");
cWriter.WriteLine("spider = off");
cWriter.WriteLine("zonegames = off");
cWriter.Close();
cStream.Close();
Process P = Process.Start(WinDir+"\\System32\\SysOCMgr.exe","/i:\""+WinDir+"\\Inf\\SysOC.Inf\" /u:\""+WinDir+"\\Temp\\SysOC.txt\" /q /r");
int Timeout = 15;
System.Threading.Thread.Sleep(5000);
while (File.Exists(WinDir+"\\System32\\SOL.EXE") && Timeout>0 && !P.HasExited)
{
System.Threading.Thread.Sleep(59000); // wait a little under 15 minutes
Timeout--;
}
if (!P.HasExited)
P.Kill();
if (P.ExitCode != 0) // SysOCMgr errored out, return error
Environment.Exit(P.ExitCode);
if (File.Exists(WinDir + "\\System32\\SOL.EXE")) // something went wrong, return generic error...
Environment.Exit(80);
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.