Please sign in to comment.
Report the correct result if the "server" service is not running
If the "server" service is not running, this module will report `false` even when the user is the administrator. By investigating further, `net.exe session` fails with the following message: ``` The Server service is not started. More help is available by typing NET HELPMSG 2114. ``` which is caught by the `.catch()` block, which returns `false` without inspecting the error object. The main issue is that `net.exe session` returns an exit code 2 both when the user has no permissions and when the server service is not running, making it impossibly to distinguish between both scenarios without inspecting the output of the command. The StackOverflow question linked from the source code addresses this concern in another answer, by proposing the use of the following command: ``` fsutil dirty query %systemdrive% >nul ``` `fsutil` is ensured to be present on Windows XP and later, and returns an exit code 0 if the user is the administrator, and exit code 1 otherwise. This commit introduces the recommended `fsutil` command, and falls back to an `fltmc` approach discussed on the same thread if `fsutil` doesn't exist (e.g: we get `ENOENT` for it). Fixes: #3 See: http://stackoverflow.com/a/21295806/1641422 Signed-off-by: Juan Cruz Viotti <firstname.lastname@example.org>
- Loading branch information...