DISKPART批处理文件脚本不是从同一个文件夹在Windows 8.1工作 [英] diskpart batch file script is not working from same folder in windows 8.1

查看:505
本文介绍了DISKPART批处理文件脚本不是从同一个文件夹在Windows 8.1工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个批处理文件来隐藏取消隐藏卷(驱动器)。
当我跑了它在我的桌面(Windows 7)中从同一文件夹中工作(批处理文件,并Diskpart脚本将在同一文件夹)
但在我的笔记本电脑(Windows 8.1),它不是来自同一个文件夹中的工作。
但是当我把脚本文件在System32下文件夹,它的工作。
如何解决这个问题?
批处理文件

 上@echo
回声隐藏键入y或取消隐藏键入n
集/ p = COMM隐藏或取消隐藏
如果不是ÿ==%COMM%转到取消隐藏
:隐藏
DISKPART / s的hide.txt
暂停
出口
:取消隐藏
DISKPART / s的unhide.txt
暂停

hide.txt

  SEL第7
 删除字母H:
 出口

unhide.txt

  SEL第7
分配
出口

当我从同一个文件夹中运行它,它显示了


  

微软的DiskPart版本6.3.9600


  
  

版权所有(C)1999至2013年微软公司。计算机:BHARGAB-PC


  
  

的DiskPart无法打开或读取脚本文件。确保
  您指定的文件存在。



解决方案

暂时把这个线你的bat文件的顶部:

 回声CD = CD%%

你'以管理员身份运行的8.1?如果是这样,改变当前目录。您可能会看到当前目录是不是你所期望的。为了解决这个问题,把下面的行附近的bat文件的顶部:

  PUSHD%〜DP0

I made a batch file to hide an unhide a volume(drive). when i ran it on my Desktop(windows 7) it worked from same folder(batch file and diskpart script in the same folder) but in my laptop(windows 8.1) it not worked from the same folder. but when i put the script file in "System32" folder it worked. how can i fix this problem? batch file

@echo on
echo to hide type y or to unhide type n
set /p comm=hide or unhide
if not y==%comm% goto unhide
:hide
diskpart /s hide.txt
pause
exit
:unhide
diskpart /s unhide.txt
pause

hide.txt

 sel vol 7
 remove letter H:
 exit

unhide.txt

sel vol 7
assign
exit

when i run it from the same folder it shows

Microsoft DiskPart version 6.3.9600

Copyright (C) 1999-2013 Microsoft Corporation. On computer: BHARGAB-PC

DiskPart was unable to open or read the script file. Make sure the file you specified exists.

解决方案

Temporarily put this line at the top of your bat file:

echo cd=%cd%

Did you 'Run as administrator' on 8.1? If so, that changes the current directory. You may see that the current directory is not what you expected. To solve this problem put the following line near the top of your bat file:

pushd %~dp0

这篇关于DISKPART批处理文件脚本不是从同一个文件夹在Windows 8.1工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆