140 lines
3.6 KiB
C#
140 lines
3.6 KiB
C#
/***********************************************************************
|
|
*
|
|
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; version 2.1
|
|
* of the License.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, Novell, Inc.
|
|
*
|
|
* To contact Novell about this file by physical or electronic mail,
|
|
* you may find current contact information at www.novell.com.
|
|
*
|
|
***********************************************************************/
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Diagnostics;
|
|
|
|
namespace sscs.init
|
|
{
|
|
/// <summary>
|
|
/// Summary description for RegCredMgr.
|
|
/// </summary>
|
|
public class CredMgr
|
|
{
|
|
public CredMgr()
|
|
{
|
|
}
|
|
|
|
public static void Install()
|
|
{
|
|
System.Diagnostics.Debug.WriteLine("CASA: attempting to register lcredmgr");
|
|
string sExePath = GetRegSvrPath();
|
|
if (sExePath != null)
|
|
{
|
|
string sCredMgrPath = GetCredMgrPath();
|
|
if (sCredMgrPath != null)
|
|
{
|
|
RunProcess(sExePath, "/i /n /s " + "\"" + sCredMgrPath + "\"");
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void Uninstall()
|
|
{
|
|
System.Diagnostics.Debug.WriteLine("CASA: attempting to unregister lcredmgr");
|
|
string sExePath = GetRegSvrPath();
|
|
if (sExePath != null)
|
|
{
|
|
string sCredMgrPath = GetCredMgrPath();
|
|
if (sCredMgrPath != null)
|
|
{
|
|
RunProcess(sExePath, "/u /s " + "\"" + sCredMgrPath + "\"");
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private static void RunProcess(string sProcess, string sArgs)
|
|
{
|
|
if (sProcess != null)
|
|
{
|
|
try
|
|
{
|
|
Process myProcess = new Process();
|
|
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(sProcess);
|
|
|
|
if (sArgs != null)
|
|
myProcessStartInfo.Arguments = sArgs;
|
|
|
|
myProcessStartInfo.UseShellExecute = false;
|
|
myProcess.StartInfo = myProcessStartInfo;
|
|
myProcess.Start();
|
|
myProcess.WaitForExit();
|
|
System.Diagnostics.Debug.WriteLine("Completed " + myProcess.ExitCode.ToString());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
System.Diagnostics.Debug.WriteLine(e.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private static string GetRegSvrPath()
|
|
{
|
|
string sPath = Environment.GetEnvironmentVariable("SystemRoot");
|
|
if (sPath != null)
|
|
{
|
|
// look for regsvr32.exe
|
|
if (File.Exists(sPath + "\\system32\\regsvr32.exe"))
|
|
{
|
|
return (sPath + "\\system32\\regsvr32.exe");
|
|
}
|
|
else
|
|
{
|
|
System.Diagnostics.Debug.WriteLine("Did not find regsvr32.exe");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
System.Diagnostics.Debug.WriteLine("Did not find System path");
|
|
}
|
|
|
|
return null;
|
|
}
|
|
private static string GetCredMgrPath()
|
|
{
|
|
string sPath = Environment.GetEnvironmentVariable("ProgramFiles");
|
|
if (sPath != null)
|
|
{
|
|
// look for regsvr32.exe
|
|
if (File.Exists(sPath + "\\Novell\\CASA\\bin\\lcredmgr.dll"))
|
|
{
|
|
return (sPath + "\\Novell\\CASA\\bin\\lcredmgr.dll");
|
|
}
|
|
else
|
|
{
|
|
System.Diagnostics.Debug.WriteLine("Did not find lcredmgr.dll");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
System.Diagnostics.Debug.WriteLine("Did not find path to [ProgramFiles]");
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|