---
title: "批处理获取路径问题总结"
author: "top5"
date: "2014-12-24T08:36:28Z"
tags: []
categories: ["操作系统"]
slug: "untitled"
draft: false
lastmod: "2014-12-24T08:36:28Z"
id: 2169646
url: "https://top5.iteye.com/blog/2169646"
---

@echo off

echo 当前盘符：%~d0

echo 当前盘符和路径：%~dp0

echo 当前批处理全路径：%~f0

echo 当前盘符和路径的短文件名格式：%~sdp0

echo 当前CMD默认目录：%cd%

PAUSE

我们以安装在C盘并使用默认系统文件夹、当前用户名是Administrator的Windows XP系统为例，罗列几个常用的系统路径所对应的绝对路径。

 

系统路径含义系统路径（不区分大小写）对应的绝对路径

当前系统盘符%systemdrive%或%HOMEDRIVE% C:\\

当前系统目录%systemroot%或%Windir% C:\\WINDOWS

当前用户文件夹%UserProfile%或%HOMEPATH% C:\\Documents and Settings\\Administrator

所有用户文件夹%AllUsersProfile% C:\\Documents and Settings\\All Users

临时文件夹1%temp%C:\\Documents and Settings\\Administrator\\Local Settings\\Temp

临时文件夹2%SystemRoot%\\TEMP C:\\WINDOWS\\Temp

程序文件夹%ProgramFiles% C:\\Program Files