tools - windows cmd: cd - to last directory

本文介绍了一种在Windows命令提示符中返回上一访问目录的方法,通过创建自定义别名实现类似Linux的'cd-'功能,并提供了一个简单的脚本示例。同时提醒用户注意避免使用特定的盘符命令来改变驱动器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In windows cmd there is no 'cd - ' where in Linux which means return to the last visited directory 

however, you can make some alias in such as way 

@echo off
if '%*'=='' cd & exit /b
if '%*'=='-' (
    cd /d %OLDPWD%
    set OLDPWD=%cd%
) else (
    cd /d %*
    if not errorlevel 1 set OLDPWD=%cd%
)


and may use doskey macro to do some alias

C:\>doskey cd=mycd $*

The only caveat is if you omit the space between cd and .. or \, you will get the builtin version ofcd not the doskey macro... and you still have to remember not to use C:D: etc. to change drive.

Please refer to the origianl discussion on "Navigating to Previous directory in Windows Command Prompot" from StackOverflow.




$ python build_update.py target_package output_package -pk ./target_package/ca.key2025-07-23 09:27:28 INFO : [] 2025-07-23 09:27:28 INFO : VERSION.mbn file parsing complete! path: target_package\updater_config\VERSION.mbn 2025-07-23 09:27:28 INFO : BOARD.list file parsing complete! path: target_package\updater_config\BOARD.list 2025-07-23 09:27:28 INFO : [] 2025-07-23 09:27:28 INFO : XML file parsing completed! 2025-07-23 09:27:28 INFO : [] 2025-07-23 09:27:54 INFO : Image system full processing completed 2025-07-23 09:28:02 INFO : Image vendor full processing completed 2025-07-23 09:28:02 INFO : All full image processing completed! image count: 2 2025-07-23 09:28:02 INFO : [] 2025-07-23 09:28:02 INFO : [] 2025-07-23 09:28:02 INFO : [] 2025-07-23 09:28:02 INFO : **************************zzy Get cmd: ['sha256sum', 'target_package/updater_config/VERSION.mbn'] 2025-07-23 09:28:03 INFO : Get hash content success! path: target_package/updater_config/VERSION.mbn 2025-07-23 09:28:03 INFO : **************************zzy Get cmd: ['sha256sum', 'target_package/updater_config/BOARD.list'] 2025-07-23 09:28:03 INFO : Get hash content success! path: target_package/updater_config/BOARD.list 2025-07-23 09:28:03 INFO : **************************zzy Get cmd: ['sha256sum', 'D:/v400/df/packaging_tools/target_package/full_imagesystem1ca_azad'] 2025-07-23 09:28:10 INFO : Get hash content success! path: D:/v400/df/packaging_tools/target_package/full_imagesystem1ca_azad 2025-07-23 09:28:10 INFO : **************************zzy Get cmd: ['sha256sum', 'D:/v400/df/packaging_tools/target_package/full_imagevendor2drt46_c'] 2025-07-23 09:28:11 INFO : Get hash content success! path: D:/v400/df/packaging_tools/target_package/full_imagevendor2drt46_c 2025-07-23 09:28:11 ERROR : Uncaught exception Traceback (most recent call last): File "D:\v400\df\packaging_tools\build_update.py", line 860, in <module> main() File "D:\v400\df\packaging_tools\build_update.py", line 851, in main if build_update_package( File "D:\v400\df\packaging_tools\update_package.py", line 473, in build_update_package update_bin_obj = create_update_bin() File "D:\v400\df\packaging_tools\update_package.py", line 142, in create_update_bin if not package.create_package(sign_algo): File "D:\v400\df\packaging_tools\create_update_package.py", line 359, in create_package package_fd = os.open(self.save_path, os.O_RDWR | os.O_CREAT, 0o755) PermissionError: [Errno 13] Permission denied: b'D:/v400/df/packaging_tools/output_package/update_bin-3swdmcl1' 2025-07-23 09:28:11 INFO : Exception occurred, Resource cleaning completed! 这个报错是怎么回事?
07-24
07-06 21:20:00.686 run_task [INFO] 执行任务前先重置计时器状态 07-06 21:20:00.686 run_task [INFO] --->> 当前使用的Agent发布版本为:2025.7.5,版本发布内容请关注readme.txt 07-06 21:20:00.686 run_task [INFO] --->> 收到任务下发,任务信息:{'blockFinishUrl': 'http://inner-api.tengwu.ias.huawei.com/api/testcase-execute/v2/testcase-block-result', 'blockId': '4906894170796785664', 'callbackDomain': 'https://apigw-cn-south.huawei.com/api/', 'customConfigParams': {'password': 'xxxxxx', 'tracemalloc': True, 'sysmonitor_collection': {'time': 60}, 'username': 'xxxxxx'}, 'enviParams': {}, 'environment': {'blockId': '4906894170796785664', 'envId': '0aab505dd5184039a86ba5461c00211c', 'envName': 'ICS_SMOKE-10.39.85.66', 'envStatus': '1', 'logicNetwork': 'ICS_SMOKE', 'teId': '10.39.85.66:8810', 'teIp': '10.39.85.66'}, 'environmentId': 'SDE-0aab505dd5184039a86ba5461c00211c', 'environmentName': 'ICS_SMOKE-10.39.85.66', 'execSource': 'failCase', 'executionUnitCustomConfig': {'creator': 'yWX1425008', 'name': 'IAS_车机_H97E_ATSID_1963', 'typeName': 'IAS_车机_H97E', 'extendField1': 'R12545271605', 'location': 'D18-4', 'id': '442c092b31194417a731a9ae841e75e5', 'sn': 'R12545271605', 'parameters': [{}], 'status': '1'}, 'executorAddr': '10.39.85.66:8810', 'failCaseReExecute': False, 'gitParams': {'gitBranch': 'br_ichu_rel', 'gitCommitId': '', 'gitGroup': '', 'gitManifest': 'c385.xml', 'gitPath': 'https://szv-open.codehub.huawei.com/TestCode/IAS/ICS/icsv100_changan_c385.git', 'gitScriptSource': 'gitmm'}, 'logicNetwork': 'ICS_SMOKE', 'originalRunTaskId': '5551183', 'product': '255947337', 'reportResultUrl': 'http://inner-api.tengwu.ias.huawei.com/api/testcase-execute/v2/testcase-result', 'roundNumber': 1, 'runTaskId': '5557083', 'singleCaseTimeout': 20000, 'softwarePackageParams': {'path': ''}, 'taskExector': 'zWX1425150', 'taskName': 'H97E__monkey', 'teIp': '10.39.85.66', 'testcaseList': [{'caseNetWork': '', 'extend': {'physicalAutoType': '', 'analyzedBy': '', 'NetworkScriptName': '', 'logicCaseOwner': '', 'rank': '3', 'physicalCaseOwner': '', 'physicalEnvtype': ''}, 'logPath': 'https://inner-api.tengwu.ias.huawei.com/vtest-log/logpath/202576/5557083/4906894136437047296/4906894170796785664/075o10jm0t0s8n5o', 'name': '整机monkey', 'number': 'TC_WDX_TF001_MOKEY001_001', 'otherLogPath': 'https://tengwu.ias.huawei.com/vtest-ics-log/icslogpath/202576/5557083/4906894136437047296/4906894170796785664/075o10jm0t0s8n5o', 'round': 1, 'type': 'TestCase', 'uri': '/071t0v9lp2kdj/077n10ae95hsj/074010jlvh929/074010jlvh93c/075o10jm0steilsd/075o10jm0stkrlth/075o10jm0stm9ltp/075o10jm0svcjm75/075o10jm0t0s8n5o/', 'version': '1'}], 'versionParams': {'bversion': 'ICHU 200.1144.170-1110500.18.B128', 'bversionUri': '/071t0v9lp2kdj/077n10ae95hsj/074010jlvh929/', 'cversion': 'ICHU 200.1144.0', 'cversionUri': '/071t0v9lp2kdj/077n10ae95hsj/'}, 'server_ready': False} 07-06 21:20:00.687 run_task [INFO] --->> 当前任务的id: 5557083 07-06 21:20:00.687 run_task [INFO] --->> 当前任务块的id: 4906894170796785664 07-06 21:20:00.687 run_task [INFO] --->> 当前任务块执行轮次: 1 07-06 21:20:00.687 run_task [INFO] --->> 检查任务是否有用例 07-06 21:20:00.687 run_task [INFO] --->> 共下发1条用例,用例类型:ICS,用例编号:['TC_WDX_TF001_MOKEY001_001'] 07-06 21:20:00.687 run_task [INFO] --->> 执行环境的设备是否正常 07-06 21:20:00.687 run_task [INFO] --->> 准备工程和资源 07-06 21:20:00.687 prepare_project_resource [INFO] 脚本来源配置信息:{'gitBranch': 'br_ichu_rel', 'gitCommitId': '', 'gitGroup': '', 'gitManifest': 'c385.xml', 'gitPath': 'https://szv-open.codehub.huawei.com/TestCode/IAS/ICS/icsv100_changan_c385.git', 'gitScriptSource': 'gitmm'} 07-06 21:20:00.687 git_mm_download_project [INFO] 通过git mm准备工程或资源,等待获取文件锁 07-06 21:20:00.703 find_repository_record [INFO] git-mm仓库地址:https://szv-open.codehub.huawei.com/TestCode/IAS/ICS/icsv100_changan_c385.git 07-06 21:20:00.703 find_repository_record [INFO] 查找仓库工作拷贝在本地的位置,请等候... 07-06 21:20:00.705 find_repository_record [INFO] 目录D:\Local\DeviceTest\20250528205032_c385发现下载记录,文件内容是'https://szv-open.codehub.huawei.com/TestCode/IAS/ICS/icsv100_changan_c385.git -b br_ichu_rel -m c385.xml' 07-06 21:20:00.705 find_repository_record [INFO] 目录D:\Local\DeviceTest\20250528205032_c385是仓库的工作拷贝 07-06 21:20:00.705 git_mm_download_project [INFO] git准备工程或资源,已获得文件锁 07-06 21:20:00.705 git_mm_download_project [INFO] 修改工作路径为:D:\Local\DeviceTest\20250528205032_c385 07-06 21:20:00.705 execute_command [INFO] execute command: git mm init -u https://szv-open.codehub.huawei.com/TestCode/IAS/ICS/icsv100_changan_c385.git -b br_ichu_rel -m c385.xml 07-06 21:20:03.980 execute_command [INFO] command's output: INFO: Start remote sync for objects of project: manifest manifest> Auto packing the repository in background for optimum performance. manifest> See "git help gc" for manual housekeeping. manifest> Nothing new to pack. manifest> warning: There are too many unreachable loose objects; run 'git prune' to remove them. INFO: manifest repository has been initialized in D:\Local\DeviceTest\20250528205032_c385 07-06 21:20:03.982 git_mm_download_project [INFO] 成功删除目录: D:\Local\DeviceTest\20250528205032_c385\icsv100_changan_c385 07-06 21:20:03.982 execute_command [INFO] execute command: git mm sync --force-sync -d 07-06 21:20:21.359 execute_command [INFO] command's output: git-mm version: 2.6.5.rc0 INFO: Start remote sync for objects of project: manifest manifest> Auto packing the repository in background for optimum performance. manifest> See "git help gc" for manual housekeeping. manifest> Nothing new to pack. manifest> warning: There are too many unreachable loose objects; run 'git prune' to remove them. INFO: local jobs num is 4, fetch jobs num is 4 Logon failed, use ctrl+c to cancel basic credential prompt. Logon failed, use ctrl+c to cancel basic credential prompt. Logon failed, use ctrl+c to cancel basic credential prompt. Logon failed, use ctrl+c to cancel basic credential prompt. INFO: Start remote sync for objects of project: TestCode/IAS/ICS/ats_framework INFO: Start remote sync for objects of project: TestCode/IAS/ICS/icsv100_changan_c385 INFO: Syncing working directory: icsv100_changan_c385 INFO: Syncing working directory: ats_framework ats_framework> CopyFile: project.config -> icsv100_changan_c385/project.config ats_framework> CopyFile: config/common-service.json -> icsv100_changan_c385/config/common-service.json ERROR: post update failed: failed to copy 'D:/Local/DeviceTest/20250528205032_c385/ats_framework/config/common-service.json' to 'D:/Local/DeviceTest/20250528205032_c385/icsv100_changan_c385/config/common-service.json' ERROR: icsv100_changan_c385> fatal: Unable to create 'D:/Local/DeviceTest/20250528205032_c385/.mm/projects/icsv100_changan_c385/TestCode/IAS/ICS/icsv100_changan_c385.git/index.lock': File exists. ERROR: icsv100_changan_c385> ERROR: icsv100_changan_c385> Another git process seems to be running in this repository, e.g. ERROR: icsv100_changan_c385> an editor opened by 'git commit'. Please make sure all processes ERROR: icsv100_changan_c385> are terminated then try again. If it still fails, a git process ERROR: icsv100_changan_c385> may have crashed in this repository earlier: ERROR: icsv100_changan_c385> remove the file manually to continue. icsv100_changan_c385 (TestCode/IAS/ICS/icsv100_changan_c385.git): icsv100_changan_c385> fatal: Unable to create 'D:/Local/DeviceTest/20250528205032_c385/.mm/projects/icsv100_changan_c385/TestCode/IAS/ICS/icsv100_changan_c385.git/index.lock': File exists. icsv100_changan_c385> icsv100_changan_c385> Another git process seems to be running in this repository, e.g. icsv100_changan_c385> an editor opened by 'git commit'. Please make sure all processes icsv100_changan_c385> are terminated then try again. If it still fails, a git process icsv100_changan_c385> may have crashed in this repository earlier: icsv100_changan_c385> remove the file manually to continue. ERROR: ERROR: Sync failed, try the following suggestions, fix errors and try 'git mm sync' again: ERROR: ERROR: step 1: run 'git mm status' to check if the working directories' status is ok ERROR: step 2: if 'step 1' doesn't help, run 'git mm sync <project>...' to check special project(s) 07-06 21:20:21.359 git_mm_download_project [INFO] 修改工作路径为:D:\DeviceTestTools\device-test-agent-windows-service 07-06 21:20:21.359 prepare_project_resource [INFO] self.project_path: 07-06 21:20:21.359 prepare_project_resource [INFO] --->> 准备工程和资源失败,失败原因如下 07-06 21:20:21.359 prepare_project_resource [ERROR] Agent-304, 本地工程路径不存在,可能是工程下载失败,请检查agent.log,路径: Traceback (most recent call last): File "D:\DeviceTestTools\device-tools-agent\agent\ticc\runner.py", line 1602, in prepare_project_resource raise AgentException(ErrorReason.NOT_FOUND_LOCAL_PATH % self.project_path) base.agent_adapter.AgentException: Agent-304, 本地工程路径不存在,可能是工程下载失败,请检查agent.log,路径: 07-06 21:20:21.365 uploadTestCaseResult [INFO] acquire lock 07-06 21:20:21.365 uploadTestCaseResult [INFO] 测试用例:TC_WDX_TF001_MOKEY001_001 07-06 21:20:21.365 uploadTestCaseResult [INFO] 执行结果:Blocked 07-06 21:20:21.365 uploadTestCaseResult [INFO] 失败原因:git mm下拉代码失败,请查看agent.log 07-06 21:20:21.366 notify_upload_log [INFO] D:\Local\ATLog\task_5557083\block_4906894170796785664_1\agent.log 路径是agent日志,不是用例日志。 07-06 21:20:21.366 _ticcReportCaseResult [INFO] ------------------------- uploadTestCaseResult Start 07-06 21:20:21.366 _ticcReportCaseResult [INFO] 上报用例的执行结果 07-06 21:20:21.371 _ticcReportCaseResult [INFO] upload result's url: https://apigw-cn-south.huawei.com/api/apigateway/tengwu/vtest/testcase-result 07-06 21:20:21.371 _ticcReportCaseResult [INFO] upload result's headers: {'request_id': '1751808021366'} 07-06 21:20:21.371 _ticcReportCaseResult [INFO] upload result's body: {'runTaskId': '5557083', 'blockId': '4906894170796785664', 'product': '255947337', 'number': 'TC_WDX_TF001_MOKEY001_001', 'startTime': 1751808021365, 'finishTime': 1751808021365, 'result': '4', 'resultInfo': 'git mm下拉代码失败,请查看agent.log', 'uri': '/071t0v9lp2kdj/077n10ae95hsj/074010jlvh929/074010jlvh93c/075o10jm0steilsd/075o10jm0stkrlth/075o10jm0stm9ltp/075o10jm0svcjm75/075o10jm0t0s8n5o/', 'localLogPath': 'D:\\Local\\ATLog\\task_5557083\\block_4906894170796785664_1\\agent.log', 'executeTeIp': '10.39.85.66'} 07-06 21:20:21.619 _ticcReportCaseResult [INFO] upload result's response: (200, {'Server': 'API-Gateway', 'Date': 'Sun, 06 Jul 2025 13:20:21 GMT', 'Content-Length': '0', 'Connection': 'keep-alive', 'Trace-Id': '1a1a7dcb868a41af89524be1f880b1c2', 'jalor-jwt-verify': 'true', 'Vary': 'Access-Control-Request-Headers', 'Gateway-Version': '6.6.8.0.RELEASE', 'Gateway-Env': 'tengwu-prod', 'Time-Trace': '755b8970-39707155,pro-gw(184.199/61738)-apig1-Route2-lb2-jwt3-server(211.85/63402-200)38-sum39', 'X-Server-Process-Time': '0.0409', 'X-Upstream-Process-Time': '0.0409', 'X-ALB-SERVER': 'ALB'}, '') 07-06 21:20:21.619 _ticcReportCaseResult [INFO] 成功上报用例的执行结果 07-06 21:20:21.619 _ticcReportCaseResult [INFO] 还有0条用例待上报 07-06 21:20:21.619 _ticcReportCaseResult [INFO] ------------------------- uploadTestCaseResult End 07-06 21:20:21.620 notify_upload_other_log [INFO] 上传的本地日志路径是:D:\Local\ATLog\task_5557083\block_4906894170796785664_1\agent.log\TC_WDX_TF001_MOKEY001_001 07-06 21:20:21.621 uploadTestCaseResult [INFO] 开启线程上传所有日志到NAS 07-06 21:20:21.621 notify_upload_other_log [INFO] D:\Local\ATLog\task_5557083\block_4906894170796785664_1\agent.log\TC_WDX_TF001_MOKEY001_001,路径在执行机上不存在 07-06 21:20:21.621 uploadTestCaseResult [INFO] release lock 07-06 21:20:24.622 _ticcReportExecutorEnd [INFO] wait for ics_tep check finished!!! 07-06 21:20:24.622 _ticcReportExecutorEnd [INFO] ABNORMAL DEVICES: [] 07-06 21:20:24.622 _ticcReportExecutorEnd [INFO] acquire lock 07-06 21:20:24.622 _ticcReportExecutorEnd [INFO] 最后一个用例的执行结果非PASS,再次检测设备状态,隔离异常设备 07-06 21:20:24.622 _ticcReportExecutorEnd [INFO] release lock 07-06 21:20:24.622 _ticcReportExecutorEnd [INFO] ------------------------- reportExecutorCmdEnd Start 07-06 21:20:24.834 _ticcReportExecutorEnd [INFO] report executor end's url: https://apigw-cn-south.huawei.com/api/apigateway/tengwu/vtest/testcase-block-result 07-06 21:20:24.834 _ticcReportExecutorEnd [INFO] report executor end's headers: {'request_id': '1751808024623'} 07-06 21:20:24.834 _ticcReportExecutorEnd [INFO] report executor end's body: {'runTaskId': '5557083', 'blockId': '4906894170796785664', 'environmentId': 'SDE-0aab505dd5184039a86ba5461c00211c', 'result': '0', 'failCaseReExecute': False} 07-06 21:20:24.834 _ticcReportExecutorEnd [INFO] response : (200, {'Server': 'API-Gateway', 'Date': 'Sun, 06 Jul 2025 13:20:24 GMT', 'Content-Length': '0', 'Connection': 'keep-alive', 'Trace-Id': '29cd44dfc67b460b9d6bc7984c82eecf', 'jalor-jwt-verify': 'true', 'Vary': 'Access-Control-Request-Headers', 'Gateway-Version': '6.6.8.0.RELEASE', 'Gateway-Env': 'tengwu-prod', 'Time-Trace': '0f66478d-39707301,pro-gw(184.199/61738)-apig1-Route1-lb2-jwt3-server(211.72/63402-200)8-sum8', 'X-Server-Process-Time': '0.0109', 'X-Upstream-Process-Time': '0.0099', 'X-ALB-SERVER': 'ALB'}, '') 07-06 21:20:24.834 _ticcReportExecutorEnd [INFO] ------------------------- reportExecutorCmdEnd End 07-06 21:20:24.834 _ticcReportExecutorEnd [INFO] ------------------------- 开始手动下发stop消息 07-06 21:20:24.834 _ticcReportExecutorEnd [INFO] 手动下发停止消息到flask's url: http://127.0.0.1:8810/api/agent/v1/testcase-block-deliver-stop 07-06 21:20:24.834 _ticcReportExecutorEnd [INFO] 手动下发停止消息到flask's headers: {'request_id': '1751808024835'} 07-06 21:20:24.834 _ticcReportExecutorEnd [INFO] 手动下发停止消息到flask's body: {'groupId': '10.39.85.66:8810', 'runTaskId': '5557083'}
07-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值