예제 #1
0
        public override void Verify()
        {
            var pars = ParamStep.GetParameters(this);
            var si = new ServiceInstaller();
            Name = _setupFile.GetKey(Name);

            _displayName = GetIfExists(pars, "servicename");
            _fileName = GetIfExists(pars, "executable");
            _user = GetIfExists(pars, "user");
            _role = GetIfExists(pars, "role");
            if (_role == "LocalService")
            {
                _user = "******";
            }
            else if (_role == "NetworkService")
            {
                _user = "******";
            }
            else if (_role == "LocalSystem")
            {
                _user = null;
            }
            _password = GetIfExists(pars, "password");

            _startType = ServiceBootFlag.Manual;
            if (!ServiceBootFlag.TryParse(GetIfExists(pars, "password"), out _startType))
            {
                _startType = ServiceBootFlag.Manual;
            }

            si.Verify(Name, _displayName, _fileName, _user, _password, _startType);
        }
예제 #2
0
        public override bool Execute(ref string template)
        {
            var si = new ServiceInstaller();

            try
            {
                si.Install(Name, _displayName, _fileName, _user, _password, _startType);
                return true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                si.Uninstall(Name);
                return false;
            }
        }