我实际上能够删除文件,但系统几乎立即恢复它们。我没有成功使用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
任何人都有任何建议???
答案 0 :(得分:1)
您可以尝试使用PowerShell脚本删除程序(不确定是否可以删除XP游戏,因为它们是Windows组件的一部分,但值得一试):How can I uninstall an application using PowerShell?
此外,发现此工具涉及删除游戏:http://www.systemtools.com/board/Forum8/HTML/000065.html
另请注意,登录脚本在登录用户的安全上下文中运行,因此如果他们不是管理员,则几乎肯定会失败。启动脚本可能更成功。
答案 1 :(得分:1)
这就是我开始工作的方式(这是以“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);
}
}
}