kavika13/RemCom

Error when opening "C:\Program Files (x86)\Vim\Vim72\vim.exe" - The system cannot find the file specified.

kavika13 opened this issue · 2 comments

I can open C:\windows\system32\notepad.exe on \\localhost, but I cannot open C:\Program Files (x86)\Vim\Vim72\vim.exe, even though the file exists.

I believe this is because it can't handle spaces in the filename.

Repro:

  1. Copy an executable file (notepad.exe) to C:\test dir with space\
  2. Launch RemCom.exe \\localhost /user:*username* /pwd:*password* "C:\test dir with space\notepad.exe"

Expected:
The program launches correctly

Actual:
An error message is displayed -

Localhost entered for Target Machine .. Going to RunAs Command

Launching Local Process ...
ERROR: API        = CreateProcessWithLogonW.
       error code = 2.
       message    = The system cannot find the file specified.

Problem no longer repros with this. Will close issue when I've uploaded a new build with the fix.

As the last patch fixes the specific case of having a space as part of your filename it breaks executing "cmd.exe" commands (dir, cd, etc...)

As an alternative I propose and deliver a patch that allows both using spaces in the comand and using cmd.exe like comands.
As a side effect of the patch, in order to send 2cmd.exe" comand you will need to issue the full command to execute. For instance to execute "dir c:" you will need to use:

RemCom.exe \remote /user:username /pwd:password "cmd.exe /c dir c:"

Its a bit longer to write commands but it works in all cases.

From the code point of view of the change the service now executes the code as:

_stprintf( szCommand, _T("%s"), pMsg->szCommand );

instead of:

_stprintf( szCommand, _T("cmd.exe /q /c "%s""), pMsg->szCommand );

And the client sends the command accordingly.

Patch is on the way.