How to run a Windows executable with different environment variables

After an update to the Google Drive desktop software, it refused to download new files created online or on another device but changes to existing files where reflected correctly.

I solved it by starting the process with a different “TEMP” environment variable:

C:\Windows\System32\cmd.exe /c 
    "SET TEMP=C:\Temp && 
     START /D ^"C:\Program Files (x86)\Google\Drive\^" googledrivesync.exe"

The Google Drive program “failed to get the inode number” of the temporary file located on my RAM drive. I did not want to change my global configuration because then all temporary files would be stored on the SSD instead of the RAM drive. So I needed to change the environment variable for just this process.

Let’s break the command down:

01  C:\Windows\System32\cmd.exe
02   /c
03    "
04     SET TEMP=C:\Temp
05     &&
06     START
07      /D
08       ^"
09        C:\Program Files (x86)\Google\Drive\
10       ^"
11      googledrivesync.exe
12    "
01  Start the Windows Command Prompt
02   Carry out the command specified by string and then terminate
03    Enclose the command string in quotation marks (START)
04     1st command: set the environment variable TEMP to a directory not on the RAM drive
05     Run the command following && only if the command preceding the symbol is successful
06     2nd command: start a separate window to run a specified program or command
07      Specify a starting directory
08       Enclose the starting directory in quotation marks which must be escaped (START)
09        The starting directory to run the program
10       Enclose the starting directory in quotation marks which must be escaped (END)
11      The actual program we want to run
12    Enclose the command string in quotation marks (END)

For completeness, the full Google Drive log:

2014-06-11 00:14:51,187 +0200 ERROR pid=252 5436:Worker-0        logging:1586 Ignoring non-fatal error: error: (1, 'GetFinalPathNameByHandle', 'Incorrect function.'), Traceback:
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/windows.fileutils", line 695, in _GetFileIdentifierAndPath

2014-06-11 00:14:51,187 +0200 ERROR pid=252 5436:Worker-0        logging:1183 GetFileIdentifierAndPath failed on path t:\temp\tmpt0g5jt
Traceback (most recent call last):
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/windows.fileutils", line 695, in _GetFileIdentifierAndPath
error: (1, 'GetFinalPathNameByHandle', 'Incorrect function.')
2014-06-11 00:14:51,187 +0200 WARNING pid=252 5436:Worker-0        logging:1602 Exception occurred during DownloadCreateCascade, path=\\?\<path><file>: InternalError: Failed to get inode number of: t:\temp\tmpt0g5jt. Exception: [Errno 2] Could not calculate Windows inode, recovery plan: 4, recovery targets: set([])
2014-06-11 00:14:51,187 +0200 ERROR pid=252 5436:Worker-0        logging:1586 Ignoring non-fatal error: InternalError: InternalError: Failed to get inode number of: t:\temp\tmpt0g5jt. Exception: [Errno 2] Could not calculate Windows inode, recovery plan: 4, recovery targets: set([]), Traceback:
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.downloads", line 688, in _CreateCascade
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.downloads", line 855, in _CreateFileForCloudEntry
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.commands", line 533, in _CreateFile
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.commands", line 595, in _DownloadToTempAndMove
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.commands", line 159, in _SetLocalModtime

2014-06-11 00:14:51,187 +0200 ERROR pid=252 5436:Worker-0        common.workers:213 Exception while processing change [ImmutableChange(Direction.DOWNLOAD, Action.CREATE, name=<file>, route=[CloudEntry(doc_id=0BxcVwWOHmGyXUGxvb1doRFhwYzA,filename=<file>,modified=1401113455,created=1401113021,acl_role=owner,doc_type=1,removed=False,parent_doc_ids=set(['0BxcVwWOHmGyXcXI5Q1AxVjd4WlU']),child_doc_ids=set([]),url=https://docs.google.com/a/kifaru.be/file/d/0BxcVwWOHmGyXUGxvb1doRFhwYzA/edit?usp=docslist_api,size=187,checksum=f6caf27e951e76abd6cc7fd51ef90161,change_stamp=21964,server_mod_time=1402435861,is_zombie=False,shared=False,resource_type=file)], rid=0BxcVwWOHmGyXUGxvb1doRFhwYzA, parent_ino=25051272927337643, is_folder=False, is_cancelled=False, cid=2, hash=-1046405062)]
InternalError: InternalError: Failed to get inode number of: t:\temp\tmpt0g5jt. Exception: [Errno 2] Could not calculate Windows inode, recovery plan: 4, recovery targets: set([])
More info: Traceback (most recent call last):
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.workers", line 191, in Process
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.persistence.sqlite", line 127, in Wrapper
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.workers", line 302, in _ProcessChanges
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.downloads", line 941, in Execute
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.downloads", line 688, in _CreateCascade
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.downloads", line 855, in _CreateFileForCloudEntry
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.commands", line 533, in _CreateFile
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.commands", line 595, in _DownloadToTempAndMove
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.commands", line 159, in _SetLocalModtime
InternalError: InternalError: Failed to get inode number of: t:\temp\tmpt0g5jt. Exception: [Errno 2] Could not calculate Windows inode, recovery plan: 4, recovery targets: set([])

2014-06-11 00:14:51,187 +0200 WARNING pid=252 5436:Worker-0        common.workers:362 Setting recovery_targets for all changes. InternalError: Failed to get inode number of: t:\temp\tmpt0g5jt. Exception: [Errno 2] Could not calculate Windows inode, recovery plan: 4, recovery targets: set([])
2014-06-11 00:14:51,187 +0200 INFO pid=252 5436:Worker-0        logging:1612 Crash reporting disabled. Ignoring report.
2014-06-11 00:14:51,187 +0200 ERROR pid=252 5436:Worker-0        logging:1586 Ignoring non-fatal error: InternalError: InternalError: Failed to get inode number of: t:\temp\tmpt0g5jt. Exception: [Errno 2] Could not calculate Windows inode, recovery plan: 4, recovery targets: set([]), Traceback:
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.workers", line 191, in Process
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.persistence.sqlite", line 127, in Wrapper
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.workers", line 302, in _ProcessChanges
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.downloads", line 941, in Execute
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.downloads", line 688, in _CreateCascade
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.downloads", line 855, in _CreateFileForCloudEntry
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.commands", line 533, in _CreateFile
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.commands", line 595, in _DownloadToTempAndMove
  File "P:\p\agents\hpam1.eem\recipes\467278470\base\b\drb\googleclient\apps\webdrive_sync\windows\build\pyi.win32\main\outPYZ1.pyz/common.worker.commands", line 159, in _SetLocalModtime

2014-06-11 00:14:51,187 +0200 INFO pid=252 5436:Worker-0        logging:1612 Crash reporting disabled. Ignoring report.
2014-06-11 00:14:51,187 +0200 ERROR pid=252 5436:Worker-0        logging:1586 The following request has been blacklisted ImmutableChange(Direction.DOWNLOAD, Action.CREATE, name=<file>, route=[CloudEntry(doc_id=0BxcVwWOHmGyXUGxvb1doRFhwYzA,filename=<file>,modified=1401113455,created=1401113021,acl_role=owner,doc_type=1,removed=False,parent_doc_ids=set(['0BxcVwWOHmGyXcXI5Q1AxVjd4WlU']),child_doc_ids=set([]),url=https://docs.google.com/a/kifaru.be/file/d/0BxcVwWOHmGyXUGxvb1doRFhwYzA/edit?usp=docslist_api,size=187,checksum=f6caf27e951e76abd6cc7fd51ef90161,change_stamp=21964,server_mod_time=1402435861,is_zombie=False,shared=False,resource_type=file)], rid=0BxcVwWOHmGyXUGxvb1doRFhwYzA, parent_ino=25051272927337643, is_folder=False, is_cancelled=False, cid=2, hash=-1046405062) Because of exception: InternalError: Failed to get inode number of: t:\temp\tmpt0g5jt. Exception: [Errno 2] Could not calculate Windows inode, recovery plan: 4, recovery targets: set(['0BxcVwWOHmGyXUGxvb1doRFhwYzA', 25051272927337643L])

Comments are closed.