简体   繁体   English

如何使用 C# 或免费的 XP 工具卸载或删除 Windows XP Sp3 游戏?

[英]How can I uninstall or delete Windows XP Sp3 Games using C# or free XP tools?

I am actually able to delete the files, but the system restores them almost immediately.我实际上可以删除这些文件,但系统几乎会立即恢复它们。 I have been unsuccessful in using sysocmgr.exe to remove games from systems and would like to do it via code (I can get sysocmgr.exe to run and remove the games if I run it manually, but it does not work for me in a login script - it gets executed and just sits there. If I do a shutdown, the files do not get removed, but if I open task manager and end the task, the files get removed)...我在使用 sysocmgr.exe 从系统中删除游戏方面没有成功,我想通过代码来完成(如果我手动运行它,我可以让 sysocmgr.exe 运行并删除游戏,但它不适用于我登录脚本 - 它被执行并坐在那里。如果我关闭,文件不会被删除,但如果我打开任务管理器并结束任务,文件会被删除)......

My uninstall batch file looks like:我的卸载批处理文件如下所示:

copy sysoc.txt "%windir%\temp\sysoc.txt" /y
sysocmgr /i:"%windir%\inf\sysoc.inf" /u:"%windir%\temp\sysoc.txt" /q /r

sysoc.txt looks like: sysoc.txt 看起来像:

[Components]
pinball = off
Solitaire = off
freecell = off
hearts = off
minesweeper = off
spider = off
zonegames = off

anyone have any suggestions???有人有什么建议吗???

You can try using PowerShell script to remove programs (not sure if you can remove XP Games as they are part of Windows Components but worth a shot): How can I uninstall an application using PowerShell?您可以尝试使用 PowerShell 脚本删除程序(不确定是否可以删除 XP 游戏,因为它们是 Windows 组件的一部分,但值得一试): 如何使用 PowerShell 卸载应用程序?

Also, found this tool that talks about removing games: http://www.systemtools.com/board/Forum8/HTML/000065.html另外,找到了这个关于删除游戏的工具: http://www.systemtools.com/board/Forum8/HTML/000065.html

Also, note that logon scripts run in the security context of the logged in user, so if they are not Admins this is almost certain to fail.另外,请注意登录脚本在登录用户的安全上下文中运行,因此如果他们不是管理员,这几乎肯定会失败。 A startup script might be more successful.启动脚本可能更成功。

This is how I got it to work (this is being executed as "SYSTEM"):这就是我让它工作的方式(这是作为“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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM