open session in Windows Service


I created application which run some macros, as desktop application it is working well, then I converted it to Windows Service also it is working well on my device but when I moved it to Client server I got :

"Connect System.Runtime.InteropServices.ComException (0x80004005): Session could not be opened"

I tried the service as (Local System, Local Service & Network Service) in all cases I got the same error.

what is the issue? I think it is permission issue but how I can solve it?

  • 0

    Is it running as a local service or under user credentials? Does the location have Sage installed locally?

  • 0 in reply to Vega

    it is running as local system (also I tried running as local service & network service).

    SAGE is installed in C:\Program Files (X86) folder, and the service is C:\TestFolder

  • 0 in reply to Yousef Bahboh

    Why is Sage installed there? By default it will choose C:\Sage\Sage300 because it sets specific permissions, whereas the permissions for Program Files is set by the OS and doesn't have the required permissions.

  • +1 in reply to Vega
    verified answer

    C:\Program Files (X86) (or the non x86) is typically the default install location for programs. By default the OS sets permissions for users to read and execute, and admins having full control - which is typically the security you want. Dumping it into c:\ adds an Autheticated Users with special permissions - which would allow this group to modify any files within that folder (unless modified by the installer). Authenticated Users according to MS are all users that have logged in with a username and password. 

    Answering the question, change your service to run as a local or domain user account. Then give that account modify rights to the Sage300 SharedData folder, and confirm it has read and execute rights to the Sage300 Program Files folder. Then restart the service.

  • 0 in reply to SergeB

    when I tried change the service to run as admin user from here 

    after I put username & password and click ok when I open the proprieties again I found it back to local system.

    when I tried make the service as user from Visual studio, when tried install the service (InstallUtil) on my device I got popup window to enter username and password but in client server I didn't get this window.

    I tried another service which only copy files and it is working well, so the issue when the service tried open session on Accpac.

    when I checked user rights assignment in local security policy in the server I can't find administrator inside "Log on as a service", I don't know if this is the reason or not

  • 0 in reply to Yousef Bahboh


    That service / log-on screen, you need to put in a local or domain windows user account; not the sage300 admin user.

    For c# service projects, I build the project, move the build dir to a folder, then use SC CREATE to create the service.

Reply Children
No Data