Windows Service created & started at startup time using Powershell script not functioning correctly

I create a new AWS Windows 2016 Server instance and provide it the script to execute through User Data.

The script first creates a Windows service, creates a new admin user, grants user the Logon as a Service right and assigns the user to that service as the Log On As user.

After the system is all set, I logon and perform the operations that this service should respond to(it accesses files on a remote network share), but it does absolutely nothing. Even my custom logs aren't getting generated. The service is like it doesn't even exist. It is running, and the new user is assigned to it. But nothing happens.

Then when I just Restart the service, it starts functioning perfectly. My assumption is that when the service is started at the startup time, it is running in some other session, and not the session to which I am logged into.

I have also tried Automatic and Automatic (Delayed) Startup type. I cannot run it using LocalSystem as I need to access remote resources with it. I have no clue what is going on here!

0
задан 14 April 2018 в 17:40
1 ответ

Удивительно, но в сценарии сразу после запуска службы я остановил, а затем снова запустил службу (с интервалом в пару секунд), и она начала работать. Странно, но факт!

0
ответ дан 5 December 2019 в 06:10

Теги

Похожие вопросы