如果在管理员模式下运行,批处理文件的工作方式将有所不同 [英] Batch file working differently if ran in administrator mode

查看:118
本文介绍了如果在管理员模式下运行,批处理文件的工作方式将有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试创建批处理文件以转换目录中的文件.通过以下代码指定目录:

I've been trying to create batch file for converting files in a directory. The directory is being given via this code:

@echo off

rem // setting input directory
:input1
set/p "inputdir=Input directory: "

rem // if input is invalid, prompt again
if not exist "%inputdir%" (
echo Directory does not exist.
echo "%inputdir%"
goto input1 
) 

效果很好-正常.但是,由于稍后考虑使用环境变量,因此我也尝试以管理员身份运行它.但是-问题是,当我正常运行它时,它会占用目录,脚本可以继续运行而不会出现问题.当我以管理员身份运行时,它充当目录不存在"

It works well - normally. However, because I've considered using environmental variables later on, I also tried running it as administrator. However - the problem is, that when i run it normally, it takes the directory, script continues without a problem. When I run in administrator more, it acts as "Directory does not exist"

它通常适用于C:和D:驱动器上的位置,此问题适用于由subst制造的O:和P:驱动器.

It works normally for locations on C: and D: drives, this issue comes up for O: and P: drives, which are made by subst.

有什么办法解决这个问题吗? 谢谢

Any idea how to solve this problem? Thank you

推荐答案

普通和提升(以管理员身份运行")进程不共享驱动器映射(默认情况下)或subst d驱动器.如果您在提升的环境中运行进程,则必须先在此处映射驱动器或在提升的环境中映射驱动器(例如,以管理员身份运行cmd.exe),然后才能尝试启动目标脚本.

Normal and elevated ("run as administrator") processes do not share drive mappings (by default) or substd drives. If you run a process in an elevated context, you'll have to map the drives there or map them in an elevated context (e.g. run cmd.exe as an administrator) before you attempt to start the target script.

参考:某些程序无法访问网络位置UAC已启用

这篇关于如果在管理员模式下运行,批处理文件的工作方式将有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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