Windows Service app is returning folder path C:\Windows\system32\ instead of project path

window application which is running windows service
It is providing

C:\Windows\system32\

instead of folder path where I have placed config files and all.

I am using following code

	filePath,err := os.Getwd()

But expect project folder path.

Because your binary file is into “C:\Windows\system32”

I got the solution

package main

import (
    "github.com/kardianos/osext"
    "fmt"
    "log"
)

func main() {
    folderPath, err := osext.ExecutableFolder()
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(folderPath)
}

Cool

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.