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 exec开发者_JS百科uted 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)...
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:
[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?
Also, found this tool that talks about removing games: 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"):
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);
}
}
}
精彩评论