File I/O from NT Service application?
1) It is possible, I've done it
It also matters whether the service is logged in as a named user. Non-named services have more limited directory permissions.
File I/O from Service definitelky works, standard Timers do not work , if your File I/O is performed on a Timer event, than it will not work, as standard timer events simply do not fire
As Philo says, it's easily done. Just remember that you will be impersonating a non-intuitive account (e.g., "SERVICE") and that your ACL's may reflect that. Make sure you log in with administrative rights if you can't seem to find the file and the returned (non) error code indicated it succeeded.
dir at badblue com
.. and don't try to write to a network drive, since you don't see it from the SYSTEM account.
If you are writing to a network drive then try and use UNC paths instead of mapped drives. Also I found that on some platforms I had to make a call to NetUseAdd first but not on others.
Thanks for the helpful pointers. Now my service works.
"Allow service to interact with desktop" has nothing to with file I/O, and if you have it checked, you probably have a security bug.
Patrik (da HaX0r?)
Fog Creek Home