Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

[Windows] Doesn't work if executable in different disk than %TEMP% #70

Closed
frontierpsycho opened this issue Mar 21, 2018 · 2 comments
Closed

Comments

@frontierpsycho
Copy link

sudo-prompt generates a batch file like the following on the fly:

@echo off
cd "path\to\executable"
"executable.exe" argument1 argument2

However, if the executable is in a different disk than the %TEMP% directory in Windows, then the cd line will fail to actually change the current working directory to where the executable is, as cd does not switch disks by default. Subsequently, sudo-prompt fails with a "could not find executable" error or somesuch.

To fix it, as discussed in this SuperUser question, you need to add /d.

I'd do a pull request, but the change is trivial:

diff --git a/index.js b/index.js
index c74ecc6..203d702 100644
--- a/index.js
+++ b/index.js
@@ -559,7 +559,7 @@ function WindowsWriteCommandScript(instance, end) {
   script.push('@echo off');
   // Set code page to UTF-8:
   script.push('chcp 65001>nul');
-  script.push('cd "' + cwd + '"');
+  script.push('cd /d "' + cwd + '"');
   script.push(instance.command);
   script = script.join('\r\n');
   Node.fs.writeFile(instance.pathCommand, script, 'utf-8', end);
@jorangreef
Copy link
Owner

Thanks @frontierpsycho good catch.

I will do the PR shortly.

@jorangreef
Copy link
Owner

Fixed in f677081

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants