首页 > 其他分享 >[902] Get the current file's directory of CMD batch scripts

[902] Get the current file's directory of CMD batch scripts

时间:2023-10-10 09:11:06浏览次数:38  
标签:902 Get CMD batch echo file directory dp0

In a batch file, you can use the %~dp0 special variable to get the directory of the currently executing batch file. Here's how you can do it:

@echo off
echo The directory of this batch file is: %~dp0

When you run this batch file, it will display the directory where the batch file is located.

Explanation:

  • %0 represents the name of the currently executing batch file.
  • %~dp0 extracts the drive and path from %0, which effectively gives you the directory of the batch file.

This is a common way to obtain the directory of the batch file within the batch script itself.

标签:902,Get,CMD,batch,echo,file,directory,dp0
From: https://www.cnblogs.com/alex-bn-lee/p/17753717.html

相关文章

  • @GetMapping、@PostMapping、@PutMapping、@DeleteMapping 的区别?
    对于@GetMapping、@PostMapping、@PutMapping、@DeleteMapping,首先我们得谈到RESTFUL风格接口,常用的URL请求方式就包括了GET、POST、PUT、DELETE等:谈到@GetMapping、@PostMapping、@PutMapping、@DeleteMapping等注解,首先得讲到@RequestMaping:@RequestMaping主要是将HTTP请求映......
  • 部署Nuget私有库3 - ProGet
    windows10、 利用ProGet搭建nuget私有库一、官方提供两种部署方式下载地址 二、exe可执行程序安装(OffineInstaller)   执行安装,等待安装完成,如下  如果选择了的是 web server,INEDOPROGETWEBSVE 服务也会running如果选择了 iis,则安装时,会自动在iis......
  • entity-framework 'scaffold-dbcontext' 未被识别为 cmdlet、函数、脚本文件或可操
    //出现此错scaffold-dbcontext:Theterm'scaffold-dbcontext'isnotrecognizedasthenameofacmdlet,function,scriptfile,oroperableprogram.Checkthespellingofthename,orifapathwasincluded,verifythatthepathiscorrectandtry......
  • QT之QWidget::paintEngine: Should no longer be called的解决办法
    这个还是以前遇到的,今天突然想起来,就决定重现一下当初的错误,以及错误的代码。报错是这个样子的:QWidget::paintEngine:ShouldnolongerbecalledQPainter::begin:Paintdevicereturnedengine==0,type:1其实这个原因很简单,来看看报错的代码:#include"mainwindow.h"......
  • 解决QWidget::paintEngine: Should no longer be called QPainter::begin: Paint devi
    标题问题同时在运行后会附带以下问题:QPainter::setPen:PainternotactiveQPainter::font:PainternotactiveQPainter::setFont:Painternotactive或QWidget::paintEngine:ShouldnolongerbecalledQPainter::begin:Paintdevicereturnedengine==0,type:1以......
  • 部署Nuget私有库1 - NuGet.Server
    概要:1、依赖  NuGet.Server包,构建自己的nuget包源服务站2、部署到iis站点3、手动上传nuget包文件4、项目引用buget包源,实现私有化包源依赖 一、搭建私有化nuget包源站点1、创建空的asp.netweb项目框架选framework6,因为nuget.server依赖的就是6版本 2、引用Nu......
  • Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round)
    Preface难得这么好时间的CF,我直接找来队友组队练题当然比赛的过程没有三人三机,就跟平时训练一样搞了个新号三人一机的写中间因为溜去先看F了导致E题留给徐神solo因此出的偏慢,不过后面一起讨论了一下还是出了最后开F结果好家伙我和祁神双双看错题,对着假题意苦战1h最后无奈投降,......
  • [893] Add comments at a batch file (CMD)
    ref:HowdoIdocommentsataWindowscommandprompt?REM isthestandardway:REMthisisacommentYoucouldalsousethedouble-colonconventioncommonlyseeninbatchfiles:::anothercommentAsinglecolonfollowedbyastringisalabel,buta......
  • 使用requests.get()得到的源代码与浏览器中的不一样
    用requests.get()之后得到的源代码跟浏览器里面的不一样崔庆才的《python3网络爬虫开发实战》在2.3.3节:我们用urllib或requests获取到的是HTML源代码,但是这个网页是用js渲染的,上面两个库不会像浏览器那样继续运行后面请求来的js模块,所以不一样。 ==================Selenium是一个......
  • Codeforces Round 902 (Div. 1, based on COMPFEST 15 - Final Round) A~D
    A.HelmetsinNightLight首先注意到一个关键性质\(b_i\geq1\),这就意味着当我们花\(p\)的代价解锁了\(b_i\)最小的后,仅凭接下来的“连锁反应”就能解锁全部的点。注意到我们“连锁反应”的一定是按\(b_i\)从小到大排序后的一段前缀(因为越往后连锁代价越昂贵),找到转折点......