Web App as Windows Service and Sqlite

I have an app installed as a Service on a windows machine. It creates an sqlite database if it does not detect one in the Documents folder. I’m a bit confused however because i ran the app before i installed it as a service and it created a database in the user’s Documents folder. When i look at the database with a regular third party db browser i can not see any data.

Does running a web app as a service have a different “Documents folder” when run this way?

I can not find any other copy of the database on the filesystem. Or am i just not able to see the data because the running web app has it locked?

Service apps run as Admin, so it may be in a different user’s Documents folder.

Sometimes they don’t even do that. If you’ve got it set up to run before anyone logs in, it could be one of the system level users like “NETWORK”.

Try using something like SpecialFolder.SharedDocuments or SpecialFolder.SharedApplicationData.

I have it running as a service whenever the user logs in. It is a local admin account. At this moment I can’t just change the location of the database as there is a good amount of data already being used so I need to find it so it can be backed up.

I suppose I could move the database that I can see and if that it where it’s creating it then it should make a new database there. If it doesn’t I have no clue where I would look.

You won’t be able to use specialfolder then. You’ll need to use GetfolderItem(“C:”).Child(“Users”).Child(“”).Child(“Documents”) etc. The service shouldn’t have any issues with permissions.

C:\Windows\System32\config\systemprofile\Documents\

This is where it ended up creating the database which is fine now that i know where it is. I just wrote a msgbox to tell me =x.

[quote=367686:@Nicholas Henson]C:\Windows\System32\config\systemprofile\Documents\

This is where it ended up creating the database which is fine now that i know where it is. I just wrote a msgbox to tell me =x.[/quote]
That looks like the location files are copied from when a new account is created. You might want to check and make sure you don’t get a copy every time an account is created.

I’d also bet that non-admin users can’t write to that location.

[quote=367910:@Greg O’Lone]That looks like the location files are copied from when a new account is created. You might want to check and make sure you don’t get a copy every time an account is created.

I’d also bet that non-admin users can’t write to that location.[/quote]

There will only ever be the one user on this device that starts the service so I should be fine. The service app does all the reading and writing. Users use the web ui served and can read and write fine.

Ok so a windows update completely wiped that directory and it no longer exist nor will it let my app recreate that space which is pretty weird so I will have to change the location.

The update also removed the service I created to run the app. Is this normal behavior?

No. I had several Windows Updates applied to my Windows web server. The service that runs my webapp was never removed, nor any of the folders I created for the application, either manually or automatically by the application. Now, I created the application folders used by the app directly on the C drive. Not under any user document folder. I did the security to allow access only to the user that runs the application and the administrator. This is currently a Windows 8.1 VM. I will have to update it to 10 pretty soon.

I would look elsewhere for a cause. Are there more than one administrators in that computer?

[quote=368730:@Louis Desjardins]I did the security to allow access only to the user that runs the application and the administrator. This is currently a Windows 8.1 VM. I will have to update it to 10 pretty soon.

I would look elsewhere for a cause. Are there more than one administrators in that computer?[/quote]

There is only one administrator and I used this command as recommended by Xojo through the cmd line run as admin:

sc create ServiceName type=own start=auto binpath=path

The command is fine.

The point is that I never saw an update remove a service, nor can we find anything to that effect on the net. The service was deleted, that is a fact. Given that it is improbable that an update did it, I was looking for some other more plausible explanation. That remains to be found.

What else is running on that server?
What automated maintenance tasks are configured on the server?

[quote=368787:@Louis Desjardins]The command is fine.

The point is that I never saw an update remove a service, nor can we find anything to that effect on the net. The service was deleted, that is a fact. Given that it is improbable that an update did it, I was looking for some other more plausible explanation. That remains to be found.

What else is running on that server?
What automated maintenance tasks are configured on the server?[/quote]

I am the only admin that works on this computer. It is just a basic windows 10 installation not an actual server. There are no automated maintenance tasks and the user does not know how to remove a service.

It was definitely caused by the update and working fine previous to the update.

I will also note that this is also the second system I have found that does not allow palette windows to move around. I have a post about it but could never resolve that issue. Works fine on my development system but when run from this users system palette windows do not function properly. My Lenovo laptop is the other system that would not allow the window to move.

I just have a knack for finding or creating weird bugs that no one else can duplicate on their systems even when I give them my source :-(.

Interesting. So an update may be the cause after all. Was the update something like the installation of a new Windows 10 version? (like 1709, for example?) A new version may be a situation where services are removed, because we are basically starting with a fresh install, with applications migrated over. Own services may not be considered in the migration. I cannot see any other situation that could do this to a system. My own systems that were updated to newer versions of Windows 10 retained the folders that I created on the system. None has a own service however, so I don’t have direct experience there. I am very interested and curious to find the conditions that would wipe folders and a service.

I also own a Lenovo Laptop. A 4th gen Carbon X1. I have Xojo installed on it and it runs windows 10. This system is indeed whimsical. This is the only system ever that I was unable to upgrade the disk. Even a bit-for-bit copy won’t boot (it does in safe mode however!).