Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command failed: C:\Users\<username>\AppData\Local\Temp\XXXX.tmp.bat (code 1) #1054

Closed
timjstone opened this issue Jan 26, 2017 · 62 comments · Fixed by #1574
Closed

Command failed: C:\Users\<username>\AppData\Local\Temp\XXXX.tmp.bat (code 1) #1054

timjstone opened this issue Jan 26, 2017 · 62 comments · Fixed by #1574

Comments

@timjstone
Copy link

timjstone commented Jan 26, 2017

  • Etcher version: Beta18
  • **Operating system and architecture: Windows 10 **

when starting Etcher, i get the following, and Etcher doesn't start

 [Window Title] Error

[Main Instruction]
Command failed: C:\Users\timjs\AppData\Local\Temp\B39C.tmp.bat


[Content]
Error: Command failed: C:\Users\timjs\AppData\Local\Temp\B39C.tmp.bat

    at ChildProcess.exithandler (child_process.js:218:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
[OK]
@jviotti
Copy link
Contributor

jviotti commented Jan 26, 2017

Looks like an issue with our drive scanner script in your PC. Can you try running the following .bat file and report back what you get? https://github.com/resin-io-modules/drivelist/blob/master/scripts/win32.bat

@timjstone
Copy link
Author

timjstone commented Jan 26, 2017

output as follows:

device: "\\\\.\\PHYSICALDRIVE1"
description: "SanDisk SSD U110 16GB"
size: 16006394880
raw: "\\\\.\\PHYSICALDRIVE1"
system: True
protected: False
mountpoints:
  - path: "D:"

device: "\\\\.\\PHYSICALDRIVE2"
description: "SanDisk Ultra Fit USB Device"
size: 124218178560
raw: "\\\\.\\PHYSICALDRIVE2"
system: False
protected: False
mountpoints:
  - path: "H:"

device: "\\\\.\\PHYSICALDRIVE0"
description: "Samsung SSD 850 PRO 512GB"
size: 512105932800
raw: "\\\\.\\PHYSICALDRIVE0"
system: True
protected: False
mountpoints:
  - path: "C:"

@jviotti
Copy link
Contributor

jviotti commented Jan 26, 2017

Can you try running echo %ERRORLEVEL% right after running the .bat command?

@timjstone
Copy link
Author

returns 0

I tested both by running it from the command line and including the the cmd file. both returned 0

Tim

@jviotti
Copy link
Contributor

jviotti commented Jan 27, 2017

Hi @timjstone ,

That's weird. Your error comes from a .bat file in a temporary location. That location is created by Electron itself when calling child_process.execFile in order to extract the executable out of the asar.

The only .bat script we have is the drive scanning script, so it must be related to it, however running it independently seems to work fine for you.

I have two theories:

  • The win32.bat script fails depending on a certain drive that is plugged to your computer

To validate this theory, try running Etcher and the win32.bat with different combinations of drives plugged in, and see if you can reproduce the failure only when a certain drive is there.

  • I pointed you to the win32.bat from the master branch, which has some fixes on top of what was released on v1.0.0-beta.18

Here is the win32.bat that was shipped with v1.0.0-beta.18: https://github.com/resin-io-modules/drivelist/blob/5.0.6/scripts/win32.bat. Can you try running that one instead?

Let me know how that goes!

@timjstone
Copy link
Author

i have checked the script and yes it is identical to the temporary bat files created and run. the file you pointed to me works the same (i.e. no errors when run manually)

i have disconnected all the drives i can (the laptop i am using has two built in drives both SSDs (one on a M2 interface)

running as an administrator still fails (so doesn't seem to be permissions related). the error seems to imply that it is having a problem closing the child process.

for reference i am using the newest Windows 10 preview build 15014

@lurch
Copy link
Contributor

lurch commented Jan 27, 2017

@jviotti Would it be easy to add some custom logging here, to determine whether the .bat file can't be executed at all, or if it started executing and failed mid-way through? (and if so, at which point it failed?)

@jviotti
Copy link
Contributor

jviotti commented Jan 27, 2017

@lurch If the script didn't complete successfully we don't inspect its stdout at all, so maybe the extra logging won't do much difference?

Most of these errors hide their root cause as subtleties in the error message. I wonder if by copy pasting the error, some of this information got lost.

@timjstone Do you mind posting a screenshot of the error window?

@timjstone
Copy link
Author

image

@jviotti
Copy link
Contributor

jviotti commented Jan 27, 2017

Weird. Maybe this is also failing because of stderr output, like #1025? @timjstone Do you mind trying this custom build?
https://drive.google.com/open?id=0B7tkbonGU-RyUnJxbm5WeVpSM1U

@timjstone
Copy link
Author

image

unfortuately, no change

Tim

@jviotti
Copy link
Contributor

jviotti commented Mar 3, 2017

I'm honestly clueless about this one. I sent a PR to drivelist to append the exit code to the error message: balena-io-modules/drivelist#149. I'll try to increase logging in some other areas and then maybe we can try again with another custom build.

@jviotti
Copy link
Contributor

jviotti commented Mar 6, 2017

@timjstone Can you run the following custom build:
https://drive.google.com/open?id=0B7tkbonGU-RyQ0tHYTVDbkRCMEU?

Once the error happens, click OK, and then once Etcher opens up, press Ctrl+Alt+I to open DevTools, go to the Console pane, and copy paste what you see there here.

@timjstone
Copy link
Author

timjstone commented Mar 6, 2017

Interested in joining the Etcher team?
Drop us a line at [email protected]
tracker.js:10 Mon Mar 06 2017 19:21:45 GMT+0000 (GMT Standard Time) Application start
tracker.js:10 Mon Mar 06 2017 19:21:45 GMT+0000 (GMT Standard Time) Checking for updates
tracker.js:10 drivelist stderr:  +0ms
tracker.js:10 drivelist stdout: device: "\\\\.\\PHYSICALDRIVE1"
description: "SanDisk SSD U110 16GB"
size: 16006394880
raw: "\\\\.\\PHYSICALDRIVE1"
system: True
protected: False
mountpoints:
  - path: "D:"

device: "\\\\.\\PHYSICALDRIVE2"
description: "SanDisk Ultra Fit USB Device"
size: 124218178560
raw: "\\\\.\\PHYSICALDRIVE2"
system: False
protected: False
mountpoints:
  - path: "H:"

device: "\\\\.\\PHYSICALDRIVE0"
description: "Samsung SSD 850 PRO 512GB"
size: 512105932800
raw: "\\\\.\\PHYSICALDRIVE0"
system: True
protected: False
mountpoints:
  - path: "C:"

device: "\\\\.\\PHYSICALDRIVE3"
description: "SDHC Card"
size: 15924142080
raw: "\\\\.\\PHYSICALDRIVE3"
system: False
protected: False
mountpoints:
  - path: "E:"

 +0ms
tracker.js:10 Error: Command failed: C:\Users\timjs\AppData\Local\Temp\6926.tmp.bat
 (code 1)
    at ChildProcess.exithandler (child_process.js:218)
    at emitTwo (events.js:106)
    at ChildProcess.emit (events.js:191)
    at maybeClose (internal/child_process.js:877)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226)a.(anonymous function) @ tracker.js:10

@timjstone
Copy link
Author

for info, when i try to select a drive in step 2, it says no removable drives.

Tim

@jviotti
Copy link
Contributor

jviotti commented Mar 6, 2017

Hi Tim,

Thank you very much for the fast response, that's really appreciated!

So it looks like the drive detection shell script exits with code 1, even though it outputs valid stuff to stdout. The question is what triggers the exit code 1.

I'm pretty sure that if it was a VBScript error, stderr would include at least a useful error message pointing the VBScript problematic line, which makes me think this comes from the batch wrapper:

set "PATH=%PATH%;%SYSTEMROOT%\System32"
cscript //nologo "%~f0?.wsf"
exit /b %ERRORLEVEL%

Here comes the nice part. If a command fails, it sets %ERRORLEVEL% to some number greater than 0, however, if after an error, a command succeeds, then %ERRORLEVEL% is NOT updated back to 0, which means that the exit code 1 could be coming from something else happening before this.

@timjstone Can you confirm that the output you pasted above includes all your connected drives?

for info, when i try to select a drive in step 2, it says no removable drives.

Yeah, that's expected. The drive scanner is failing, so you'll not be able to select any drives.

@jviotti
Copy link
Contributor

jviotti commented Mar 6, 2017

In order to confirm this theory, I'll create a new custom build that resets the error level at the beginning of the batch script.

@jviotti
Copy link
Contributor

jviotti commented Mar 6, 2017

The way that error level works is absurd. Almost no command resets the error level, but some internal ones do. Even worse, if you do set ERRORLEVEL 0, then that creates a new environment variable that shadows the real one, causing an even bigger mess.

jviotti pushed a commit to balena-io-modules/drivelist that referenced this issue Mar 6, 2017
Turns out ERRORLEVEL might carry errors from previous commands, given
that not every command resets it when exitting successfully.

This prevents us from getting false error alerts and helps us know for
sure that an exit code originated from drivelist.

See: balena-io/etcher#1054
Signed-off-by: Juan Cruz Viotti <[email protected]>
@jviotti
Copy link
Contributor

jviotti commented Mar 6, 2017

@timjstone Here's a new custom build containing the patch described above: https://drive.google.com/open?id=0B7tkbonGU-Ryb1hybnVvYlYtQ1k

Let us know how it goes, and thank you very much for you help debugging this issue!

@timjstone
Copy link
Author

unfortunately, the same problem

Tim

@jviotti
Copy link
Contributor

jviotti commented Mar 6, 2017

@timjstone Is it the same code number in the error title? E.g: (code 1)

@jviotti
Copy link
Contributor

jviotti commented Mar 6, 2017

@timjstone Do you mind trying this little program? https://drive.google.com/file/d/0B7tkbonGU-RyT0Z0Qm8zOHFuVk0/view?usp=sharing You should execute it from cmd.exe or PowerShell by running the run.bat script in there.

Its basically Node v6.1.0 (which we use on Etcher) calling drivelist. If this fails with the same error message, then we're in good track, since we'd have a very small reproducible example. If this doesn't fail, then I honestly have no clue about what might be going on, so let's hope it fails :)

@timjstone
Copy link
Author

timjstone commented Mar 7, 2017 via email

@jviotti jviotti changed the title error Starting Etcher on Windows (Beta18) Command failed: C:\Users\<username>\AppData\Local\Temp\XXXX.tmp.bat Mar 8, 2017
@timjstone
Copy link
Author

I only use Windows defender, no other anti virus installed, if that is any help

Tim

@lurch
Copy link
Contributor

lurch commented May 3, 2017

*shrug* I suspect there's so many different virus-scanner programs, who knows how they all work! ;-)

@jviotti jviotti modified the milestones: v1.0, Backlog May 9, 2017
@alexandrosm
Copy link
Contributor

alexandrosm commented May 11, 2017 via email

@lurch
Copy link
Contributor

lurch commented May 12, 2017

@alexandrosm My comment was directed at @jhermsmeier , rather than at @timjstone ;)

@jviotti jviotti modified the milestones: Backlog, 1.1 Jun 20, 2017
jviotti added a commit that referenced this issue Jul 6, 2017
This version contains various improvements on the drive detection system
mainly on Windows. The improvements can be summarized as follows:

- Drivelist no longer spawns a .bat script to perform its job. This
  means that a lot of spawning related issues are now fixed

- Drivelist doesn't fetch drive sizes from WMI anymore, which was known
  to incorrectly report a very small size for certain drives, causing
  the famous "0.0 GB" Windows issues (see
  balena-io-modules/drivelist#142)

Change-Type: patch
Changelog-Entry: Implement Windows drive detection using C++
Changelog-Entry: Fix various Windows `.bat` spawning issues
Changelog-Entry: Fix 0.0 GB Windows drive detection issues
Fixes: #1108
Fixes: #1054
Fixes: #995
Fixes: #1483
Fixes: #1142
Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti added a commit that referenced this issue Jul 6, 2017
This version contains various improvements on the drive detection system
mainly on Windows. The improvements can be summarized as follows:

- Drivelist no longer spawns a .bat script to perform its job. This
  means that a lot of spawning related issues are now fixed

- Drivelist doesn't fetch drive sizes from WMI anymore, which was known
  to incorrectly report a very small size for certain drives, causing
  the famous "0.0 GB" Windows issues (see
  balena-io-modules/drivelist#142)

- Cleanup temporary scripts after execution

Change-Type: patch
Changelog-Entry: Implement Windows drive detection using C++
Changelog-Entry: Fix various Windows `.bat` spawning issues
Changelog-Entry: Fix 0.0 GB Windows drive detection issues
Changelog-Entry: Cleanup drive detection temporary scripts created for other operating systems
Fixes: #1108
Fixes: #1054
Fixes: #995
Fixes: #1483
Fixes: #1142
Fixes: #1571
Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti added a commit that referenced this issue Jul 11, 2017
This version contains various improvements on the drive detection system
mainly on Windows. The improvements can be summarized as follows:

- Drivelist no longer spawns a .bat script to perform its job. This
  means that a lot of spawning related issues are now fixed

- Drivelist doesn't fetch drive sizes from WMI anymore, which was known
  to incorrectly report a very small size for certain drives, causing
  the famous "0.0 GB" Windows issues (see
  balena-io-modules/drivelist#142)

- Cleanup temporary scripts after execution

Change-Type: patch
Changelog-Entry: Implement Windows drive detection using C++
Changelog-Entry: Fix various Windows `.bat` spawning issues
Changelog-Entry: Fix 0.0 GB Windows drive detection issues
Changelog-Entry: Cleanup drive detection temporary scripts created for other operating systems
Fixes: #1108
Fixes: #1054
Fixes: #995
Fixes: #1483
Fixes: #1142
Fixes: #1571
Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti added a commit that referenced this issue Jul 11, 2017
This version contains various improvements on the drive detection system
mainly on Windows. The improvements can be summarized as follows:

- Drivelist no longer spawns a .bat script to perform its job. This
  means that a lot of spawning related issues are now fixed

- Drivelist doesn't fetch drive sizes from WMI anymore, which was known
  to incorrectly report a very small size for certain drives, causing
  the famous "0.0 GB" Windows issues (see
  balena-io-modules/drivelist#142)

- Cleanup temporary scripts after execution

Change-Type: patch
Changelog-Entry: Implement Windows drive detection using C++
Changelog-Entry: Fix various Windows `.bat` spawning issues
Changelog-Entry: Fix 0.0 GB Windows drive detection issues
Changelog-Entry: Cleanup drive detection temporary scripts created for other operating systems
Fixes: #1108
Fixes: #1054
Fixes: #995
Fixes: #1483
Fixes: #1142
Fixes: #1571
Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti added a commit that referenced this issue Jul 12, 2017
This version contains various improvements on the drive detection system
mainly on Windows. The improvements can be summarized as follows:

- Drivelist no longer spawns a .bat script to perform its job. This
  means that a lot of spawning related issues are now fixed

- Drivelist doesn't fetch drive sizes from WMI anymore, which was known
  to incorrectly report a very small size for certain drives, causing
  the famous "0.0 GB" Windows issues (see
  balena-io-modules/drivelist#142)

- Cleanup temporary scripts after execution

This PR also sets the DRIVELIST_DEBUG environment variable to enable
debug information from Windows' drivelist implementation.

Change-Type: patch
Changelog-Entry: Implement Windows drive detection using C++
Changelog-Entry: Fix various Windows `.bat` spawning issues
Changelog-Entry: Fix 0.0 GB Windows drive detection issues
Changelog-Entry: Cleanup drive detection temporary scripts created for other operating systems
Fixes: #1108
Fixes: #1054
Fixes: #995
Fixes: #1483
Fixes: #1142
Fixes: #1571
See: https://github.com/resin-io-modules/drivelist/blob/master/CHANGELOG.md
Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti added a commit that referenced this issue Jul 12, 2017
This version contains various improvements on the drive detection system
mainly on Windows. The improvements can be summarized as follows:

- Drivelist no longer spawns a .bat script to perform its job. This
  means that a lot of spawning related issues are now fixed

- Drivelist doesn't fetch drive sizes from WMI anymore, which was known
  to incorrectly report a very small size for certain drives, causing
  the famous "0.0 GB" Windows issues (see
  balena-io-modules/drivelist#142)

- Cleanup temporary scripts after execution

This PR also sets the DRIVELIST_DEBUG environment variable to enable
debug information from Windows' drivelist implementation.

Change-Type: patch
Changelog-Entry: Implement Windows drive detection using C++
Changelog-Entry: Fix various Windows `.bat` spawning issues
Changelog-Entry: Fix 0.0 GB Windows drive detection issues
Changelog-Entry: Cleanup drive detection temporary scripts created for other operating systems
Fixes: #1108
Fixes: #1054
Fixes: #995
Fixes: #1483
Fixes: #1142
Fixes: #1571
See: https://github.com/resin-io-modules/drivelist/blob/master/CHANGELOG.md
Signed-off-by: Juan Cruz Viotti <[email protected]>
@lurch
Copy link
Contributor

lurch commented Jul 13, 2017

Please see #1574 (comment)

@babi-bibaak
Copy link

babi-bibaak commented Jan 1, 2018

Hello,
i have this error and can't fix that!!!
image
untitled
untitled

@jhermsmeier
Copy link
Contributor

@babi-bibaak that error doesn't seem to have anything to do with Etcher

@lurch
Copy link
Contributor

lurch commented Jan 2, 2018

@babi-bibaak Please ensure that you're using the latest version of Etcher v1.2.1

@frankgorhamengard
Copy link

I posted a solution that worked for me in #1793
SD micro card was plugged in to a USB adapter when it was formatted by SD formatter. But after I reformatted in the SD adapter, I was able to install the image successfully with Etcher.
Something about formatting in a USB adapter?

@kriekprinsloo
Copy link

kriekprinsloo commented Sep 14, 2018 via email

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

Successfully merging a pull request may close this issue.

14 participants