Application . net does not create service in windows (sc create)

Asked

Viewed 24 times

0

I have the following code:

public static void CriarServico(string nomeServico, string caminhoExecutavel)
        {
            try
            {
                string arguments = string.Format("create {0} binPath={1} type=own start=auto", nomeServico, caminhoExecutavel);
                var scCreate = new ProcessStartInfo();
                scCreate.FileName = "sc.exe";
                scCreate.UseShellExecute = true;
                scCreate.Verb = "runas";
                scCreate.Arguments = arguments;
                Process.Start(scCreate);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

But when this method is executed, the service is not created, I believe IIS permission is missing.

There is another way for the system to create the service?

  • Any Exception? Are you looking to register windows services for a web application? The pool user has admin level?

  • Actually there was no Exception, which would give me a north. When debugging, the code follows until the end of the method and has no error, but does not register the service

  • Nothing? not even on Event Viewer? Have you tried adding this service manually and check if the problem is not in it?

  • just to make sure... you intend to register the service on the same machine of the IIS right? not the user who is accessing the application, correct? I have to ask, because I’ve seen it all here.

  • Manually it is logged without problems and yes, it will be in the same machine that IIS is. Even changed the profile of the application by giving it an administrator’s username and password

  • Then the problem should be only the warning that it can present when trying to register the service

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.