0

I have a script that initiates and monitors two io.filesystemwatchers that process data automatically. It works flawlessly in ISE and as a batch file, but when I tried to run it as a task and as a service it doesn't appear to function at all. I tried installing it using NSSM with the arguments -ExecutionPolicy Bypass -NoProfile, and later added -NoLogo -NonInteractive when the previous set did not work. I tried checking local system account and allow service to interact with desktop. I tried to check this account and set tie it to the local admin account but it yields a 1069 logon error.

What else can I do and what should I try?

Andy
  • 207
  • 4
  • 18
  • Add Start-Transcript to the start of your script and direct the output to a log file. You can then see from there what is failing. This question is asked many times on SO - do a search for it before you go any further with this. – Scepticalist Feb 19 '20 at 07:50
  • I tried. When running as a batch file it said it was starting the log, but it did not actually create a log file. It also did not create one when I started the service – Andy Feb 19 '20 at 08:04
  • If "Start-Transcript -Path pathname" does not create a log then that's likely an issue with the access to the path - Check credentials, which also happens to be the likely cause of all your issues. – Scepticalist Feb 19 '20 at 08:14
  • @Andy - you can download procmon from sysinternals to get some insight as what is executed with what security context. Alternatively, I would suggest to first create a script as simple as possible and verify if that runs without issues. – Lieven Keersmaekers Feb 19 '20 at 08:15
  • @Scepticalist I see now it is misinterpreting "Desktop/log.txt" as "Desktop/Desktop/log.txt" for some reason. Also, starting the service does not even trigger the creation of the log. – Andy Feb 19 '20 at 08:38
  • I have been trying to change the log on settings under properties of the service, but any time I try to change it (either to default or admin) when I restart the service I get a 1069 logon failure. I have local admin rights to this computer, should I consult IT about this? – Andy Feb 19 '20 at 08:42
  • If you're on a domain, you shouldn't even be trying to do this without asking IT. On domains, accounts need "Logon As a Service" rights to run as a service and this is not usually automatically assigned. – Scepticalist Feb 19 '20 at 09:46
  • Ohhh okay. I requested local admin rights for the computer and in the justification part of the application I specifically explained what I planned to do, I guess I assumed that would take care of all access related issues. – Andy Feb 19 '20 at 09:51

0 Answers0