diff --git a/service.go b/service.go index e80b051..f4fee70 100644 --- a/service.go +++ b/service.go @@ -34,3 +34,10 @@ type Service interface { LogWarning(format string, a ...interface{}) error LogInfo(format string, a ...interface{}) error } + +// Returns the full path of the running executable +// as reported by the system. Includes the executable +// image name. +func GetExePath() (exePath string, err error) { + return getExePath() +} diff --git a/service_windows.go b/service_windows.go index 6f40a16..cc2c010 100644 --- a/service_windows.go +++ b/service_windows.go @@ -104,6 +104,10 @@ func (ws *windowsService) LogInfo(format string, a ...interface{}) error { return writeToEventLog(ws.name, fmt.Sprintf(format, a ...), levelInfo) } +func getExePath() (exePath string, err error) { + return getModuleFileName() +} + var ( advapi = syscall.MustLoadDLL("advapi32.dll") kernel = syscall.MustLoadDLL("kernel32.dll")