Could not find a part of path error on server

前端 未结 2 630
广开言路
广开言路 2021-01-26 22:29

I want to run a scheduler on daily basis. So I have created a Windows application and stored it onto the server.

This works fine on my local machine, but I g

2条回答
  •  不要未来只要你来
    2021-01-26 23:07

    You probably assumed that when you installed your service, it'd run on the path where it is installed from but services on Windows are run by "Service Control Manager" (scm) which is usually located on C:\Windows\System32

    So, your service gets the C:\Windows\System32 value as CurrentPath()

    You could try:

    startupPath = System.AppDomain.CurrentDomain.BaseDirectory;

    *Edit: For those who might want to check the path for scm, the file that you need to check is sc.exe As in sc command that you use to install,start,etc. a service.

提交回复
热议问题