0

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)...

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???

Stephen Lee Parker
  • 1,215
  • 9
  • 19
  • 1
    Is there a reason you can't just use Windows Add/Remove programs to get rid of the games? – Jeff Machamer Jul 11 '11 at 17:30
  • @Jeff: It's a sysadmin issue. He wants to automate the removal of games from business machines using a login script, and not have to hassle with manual removal for every machine. – Robert Harvey Jul 11 '11 at 17:32
  • Then probably belongs to serverfault.com? – Mrchief Jul 11 '11 at 17:57
  • @Mrchief: Well, to answer the question, programming expertise is needed. The code the OP has already works, it just doesn't work from a login script. Which makes sense, since you don't want rogue programs in your login script mucking with what Windows considers part of its system structure. Or, something required by the code loads *after* the login script executes. – Robert Harvey Jul 11 '11 at 18:04
  • Right. Maybe C# isn't the answer then. How about looking at some powershell based scripting? You can run your .net code and also access low level Win APIs that will to add/remove programs: http://stackoverflow.com/questions/113542/how-can-i-uninstall-an-application-using-powershell – Mrchief Jul 11 '11 at 18:11

2 Answers2

1

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.

Community
  • 1
  • 1
Mrchief
  • 75,126
  • 20
  • 142
  • 189
  • The link you provided lead me to the answer. I do not know why I did not think to write a C# app to run sysocmgr.exe and terminate it after x minutes... The vbscript in the link does not terminate sysocmgr.exe, but all the same it lead me to the answer – Stephen Lee Parker Jul 13 '11 at 12:46
1

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);
        }
    }
}
Stephen Lee Parker
  • 1,215
  • 9
  • 19