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

Created on 26 Jan 2017  Â·  62Comments  Â·  Source: balena-io/etcher

  • 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]
windows bug

All 62 comments

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

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:"

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

returns 0

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

Tim

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!

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

@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?)

@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?

image

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

image

unfortuately, no change

Tim

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

@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.

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

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

Tim

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.

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.

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.

@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!

unfortunately, the same problem

Tim

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

@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 :)

yes we get the same error

or: Command failed: C:\Program Files
(x86)\Etcher\node_modulesdrivelist\scriptswin32.bat
(code 1)
at ChildProcess.exithandler (child_process.js:202:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:850:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)

On Mon, 6 Mar 2017 at 21:13 Juan Cruz Viotti notifications@github.com
wrote:

@timjstone https://github.com/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
:)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/resin-io/etcher/issues/1054#issuecomment-284534308,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AYMUjF8dzWOJnIuA1GI31euwU9Lx_-M_ks5rjHcRgaJpZM4Lur9t
.

C:\Users\xxxxx\tmp>win32.bat
device: "\\\\.\\PHYSICALDRIVE0"
description: "SAMSUNG MZ7TD256HAFV-000 SCSI Disk Device"
size: 256052966400
raw: "\\\\.\\PHYSICALDRIVE0"
system: True
protected: False
mountpoints:
  - path: "C:"

device: "\\\\.\\PHYSICALDRIVE1"
description: "Kingston DataTraveler 3.0 USB Device"
size: 15471751680
raw: "\\\\.\\PHYSICALDRIVE1"
system: False
protected: False
mountpoints:
  - path: "E:"


C:\Users\xxxxx\tmp>echo %ERRORLEVEL%
0

Hi @timjstone @pfmscc ,

Do you mind trying my suggestion from https://github.com/resin-io/etcher/issues/1054#issuecomment-284534308?

The above experiment will validate if this is an issue on Electron or not.

No failure.

C:\Users\xxxxx\tmp\drivelist-test\drivelist-test>run.bat
[
  {
    "device": "\\\\.\\PHYSICALDRIVE0",
    "description": "SAMSUNG MZ7TD256HAFV-000 SCSI Disk Device",
    "size": 256052966400,
    "raw": "\\\\.\\PHYSICALDRIVE0",
    "system": true,
    "protected": false,
    "mountpoints": [
      {
        "path": "C:"
      }
    ]
  },
  {
    "device": "\\\\.\\PHYSICALDRIVE1",
    "description": "Kingston DataTraveler 3.0 USB Device",
    "size": 15471751680,
    "raw": "\\\\.\\PHYSICALDRIVE1",
    "system": false,
    "protected": false,
    "mountpoints": [
      {
        "path": "E:"
      }
    ]
  }
]

Is the *.tmp.bat error the same one as the win32.bat error? I recently recommended Ether to my coworkers only to have a lot of them get stuck with this error. They are all running Windows 10 x64.

Error

I think they were the same. I am also running Win 10 64-bit.

Hi @d4rk22 @pfmscc ,

They are the same. The win32.bat happens if the application is not packaged as an asar (extracting them from the asar for execution purposes makes the file get a temporary name).

I recently recommended Ether to my coworkers only to have a lot of them get stuck with this error. They are all running Windows 10 x64.

That's very weird. The Etcher team is struggling a lot with this because we can't reproduce in any of our computers (we're also running Windows 10 x64). Is there any special Windows configuration your co-workers have that could be triggering this issue?

Do you mind trying the things I asked on this thread, and confirm that you get the same results? I'm starting to think there is en Electron bug here, but it'd be impossible to debug without getting my hands on a computer that reproduces the bug, building Electron, and playing with it myself.

a thought. i am running the insiders preview of windows 10 x64. could this be the issue?

Tim

Hi @timjstone ,

Yeah, that would make sense. What insider preview are you running? Could you link me to an image that gives me the closest possible environment to yours? (I'm an insider member already)

BTW, can someone clarify if this error happens as soon as you start Etcher, or as soon as you click "Flash"?

I am pretty sure it was on startup.

Once you click to get rid of the error pop-up, the rest of the etcher window comes up but the middle icon does nothing.

i am running todays 15060 (i am on the fast ring) - the error still occurs.

Etcher did work in the past (but i can't remember on which build i was on, but it was a long time ago)

Cool, I'll install it and see how it goes next week.

@timjstone On what insider level are you?

capture

i am on the fast ring - i like to live dangerously!

Are these standalone PCs, or are they on some kind of corporate network?

standalone (not part of a domain)

tim

Does the same error occur if you boot the PCs in Safe Mode?

just to update, i have installed the win32 version for a test (instead of the x64 version installed previously) and all seems to work. so the problem seems to be with the x64 version .

Thanks for the info @timjstone. I managed to setup my Windows 10 x64 machine into the fast insider level, but I still can't reproduce the issue :(

Happens to me in Win 7 64 when i open the app

Damn, I truly wish I could reproduce this :/ The more I investigate it the more it seems the issue comes from Electron, but I can't know for sure without being able to actively reproduce.

@ShalokShalom Was the Windows 7 installation customized in any way that I could try mimicking here?

Also, does it happen if you open the app while there are no drives plugged in? Could it be that certain drives trigger the issue?

Sorry, this happened on a consumer device, about which i already forgot xD
All what i was aware, is that it was a pretty untouched, unmodified version of Windows 7.

Hello,

I have the same error as described (screenshot).

Here's what I get when I run the .bat script that @jviotti recommended:

Erreur CScript: L'accès à Windows Script Host est désactivé sur cette machine. Contactez votre administrateur système pour plus d'informations.

It basically says that Windows Script Host is disabled (I disabled it some time ago for security reasons).

Is there any way you could avoid using WSH for whatever you're trying to do in the .bat script (and in Etcher, if the two issues are related)?

Thanks!

There _is_ a plan to replace drivelist with a native NodeJS module, but until then I'm afraid re-enabling WSH is your only option.
(Etcher uses VBscript on Windows to gather information about what drives are available on your system, how big they are, etc. etc.)

@lurch Maybe you could test the absence of WSH and throw a specific error message in case that happens :) anyway, thank you for your answer.

Sounds like a good suggestion :+1:

@jviotti I did a quick bit of research, and it seems the only way we can tell if WSH is disabled is by reading the registry https://technet.microsoft.com/en-us/library/ee198684.aspx
Also found a native module that allows registry access https://www.npmjs.com/package/windows-registry
Happy to put a PR together for this next week, if you think it's worth it.

P.S. Ooh, just spotted that that NPM module also has "Launching a Process as an Admin" functionality ;-)

I am getting this error too

image

image

In a recent team-meeting, @jhermsmeier suggested that perhaps a virus-checker was responsible for #1108 - perhaps the same is also true for this issue?
I.e. maybe the XXXX.tmp.bat is only partially written out to disk (due to delays caused by a virus-scanner), before Etcher tries running it? I wonder if a workaround might be waiting until the XXXX.tmp.bat extracted from the .asar has the size we expect it to, before we try executing it?

@lurch I think antivirus software will just acquire exclusive access to those files, not stall writes, which might be the reason Etcher can't "see" it, until the file is released. So stat-ing the file (checking it's size) likely won't work either. I think we'd need to repeatedly try to execute it, until it succeeds, or we give up. This theory needs validation though.

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

Tim

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

@lurch "windows defender" is the default microsoft one.

--

Alexandros Marinos

Founder & CEO, Resin.io

+1 206-637-5498

@alexandrosm

On Wed, May 3, 2017 at 7:39 PM, Andrew Scheller notifications@github.com
wrote:

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

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/resin-io/etcher/issues/1054#issuecomment-298998983,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABLUCFFjfXHwWpZvCXwMRguntfV-_Hbmks5r2MnxgaJpZM4Lur9t
.

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

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

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

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

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?

Which USB adapter are you using? I own a USB cd/DVD adapter, and it's just
not very high quality and doesn't work most times I try to use it.

On Thu, Sep 13, 2018 at 6:57 PM, Frank Gorham-Engard <
[email protected]> wrote:

I posted a solution that worked for me in #1793
https://github.com/resin-io/etcher/issues/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?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/resin-io/etcher/issues/1054#issuecomment-421206190,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADpgDjP86Ydp-w3K-rHch-6CbofSdWOtks5uawz1gaJpZM4Lur9t
.

Was this page helpful?
0 / 5 - 0 ratings