Elevated command prompt vs. Run as administrator

I've been looking for an answer on this particular question. The situation is as follows:

  • I have a .cmd file that starts up a NodeJS script that creates/deletes/alters windows services of an application. This is done using the package node-windows and also requires some access to the file system to retrieve some parameters.

  • The content of the .cmd file is very simple:

@echo off
echo <some_text>.
node <relative_path_to_file>\utils-services.js start all

What I notice is the following:

  1. When run using a right-mouse click and selecting Run as Administrator this fails
  2. When run from an elevated command prompt this succeeds.

The question now is, what is the difference between the two that causes this behavior ? I'm really curious and could not find an adequate answer. Thank you in advance!

1 answer

  • answered 2020-10-23 08:54 user14505446

    The difference from you to others is you are always asking Windows to guess what you want.

    Just tell it. No relative paths, simple.