'cmd.exe /C echo %TEMP%').strip() if not remotePath.endswith('\\'): remotePath = remotePath + '\\' remotePath = remotePath + inq srcInq = File(path) tmpInq = File.createTempFile( srcInq.getName() + '-' + os_handle.getSession().getHost() + '-' + str(System.currentTimeMillis()), None) if not tmpInq.exists(): tmpInq.createNewFile() source = None destination = None try: source = FileInputStream(srcInq).getChannel() destination = FileOutputStream(tmpInq).getChannel() destination.transferFrom(source, 0, source.size()) finally: if source != None: source.close() if destination != None: destination.close() try: os_handle.copyToRemote(tmpInq.getCanonicalPath(), remotePath) WindowsAgentUtils.setWindowsFilePermissions( remotePath, os_handle.getSession()) finally: tmpInq.delete() cmdGatewayCleanup = 'cmd.exe /C del /F ' + tmpInq.getName() try: os_handle.executeCommandOnGateway(cmdGatewayCleanup, 60000, None)