ServiceApplication works in Console, no output as a service

  1. 3 months ago

    Eugene D

    Aug 9 Pre-Release Testers, Xojo Pro Canada scispec.ca

    Hello,

    I am doing some work with a Windows ServiceApplication and when I run the application it correctly writes a file with an updated value every 5 seconds with a timer. When I launch the application as a service, no file is written on Windows. Not sure what I am doing incorrectly or what I am missing? Any thoughts?

    I changed the App's super to a ServiceApplication, and installed the service with the following sc command:

    sc create Text type= own start= auto binpath= c:\Test\TestServices.exe

    Service installation works well. I start the application and its supposed to overwrite a file to the desktop every 5 seconds with the added text value of elapsed seconds (5, 10, 15,etc). I start the service, and all is successful to this point. Unfortunately, there is no file created on the desktop. If I run the program in a command prompt or double click the program in an explorer window, then it works well and creates and overwrites the file every 5 seconds. Is there maybe an elevated permission needed to write a file with a ServiceApplication?

    Here is the example file:
    TestServices.zip

    Thanks for your help :)

  2. Wayne G

    Aug 9 Pre-Release Testers, Xojo Pro Answer New Zealand axisdirect.nz

    The output file will be C:\Windows\System32\config\systemprofile\Desktop\TestService.txt, but you won't have access to the folder unless you change permissions. Perhaps output to a folder on C:?

  3. Eugene D

    Aug 9 Pre-Release Testers, Xojo Pro Canada scispec.ca

    Thanks for the help Wayne. I'll try the modifications tomorrow after work.

  4. Greg O

    Aug 10 Xojo Inc

    Right. Check the user that the service is running as. That’s the desktop it’ll show up under.... and only if it has permissions to do so (some users are not interactive and don’t actually have user folders like Desktop)

  5. Eugene D

    Aug 10 Pre-Release Testers, Xojo Pro Canada scispec.ca

    @Wayne G The output file will be C:\Windows\System32\config\systemprofile\Desktop\TestService.txt, but you won't have access to the folder unless you change permissions. Perhaps output to a folder on C:?

    This worked! Thanks Wayne. I modified the line of code to point to a C:\Test\ directory and it works when running.

    f= New FolderItem("c:\Test\TestService.txt")

    @Greg OLone Right. Check the user that the service is running as. That’s the desktop it’ll show up under.... and only if it has permissions to do so (some users are not interactive and don’t actually have user folders like Desktop)

    This is interesting as I am the only user on my development computer and when I use the SpecialFolder.Desktop.Child("TestService.txt") location then the file does not appear, as it must be writing the information somewhere else.

    f=SpecialFolder.Desktop.Child("TestService.txt")

    Changing the code to point to my account desktop works:

    f= New FolderItem("C:\Users\eugen\Desktop\TestService.txt")

    Great information Wayne and Greg, thanks for your help!!

  6. Greg O

    Aug 10 Xojo Inc

    try sending SpecialFolder.Desktop.ShellPath to your log. I bet it doesn't point where you think.

  7. Eugene D

    Aug 10 Pre-Release Testers, Xojo Pro Canada scispec.ca

    @Greg OLone try sending SpecialFolder.Desktop.ShellPath to your log. I bet it doesn't point where you think.

    I must not have permission, since my computer will not allow me to get the ShellPath information. I learn something new every day. Greg, your right, as the path doesn't go where I thought it should. :)

  8. Tim H

    Aug 10 Pre-Release Testers Portland, OR USA

    @Eugene D I am the only user on my development computer

    Technically, you're not. There are special system users. By default, a service does not run as you. It runs as SYSTEM. You could set it to run as you, but I usually use SpecialFolder.SharedApplicationData.

or Sign Up to reply!