运行批处理文件以管理员身份 - Windows 7的 - 指挥QUOT;运行方式"从网络文件系统 [英] Run Batch file as administrator - Windows 7 - Command "Run As" from network file system

查看:207
本文介绍了运行批处理文件以管理员身份 - Windows 7的 - 指挥QUOT;运行方式"从网络文件系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要建立一个程序的安装程序的交付。

I need to set up the delivery of a program installer.

该程序具有program_installer.exe和文件夹,我不能在我创建的安装程序时,安装程​​序包括

This program has a program_installer.exe and a folder that i cannot include in the installer at the time in which i create the installer.

因此​​,当用户需要安装的程序我送他一个批处理文件,通过邮件

therefore, when a user needs to install the program i send him a BATCH file via MAIL

@echo off
if DEFINED PROGRAMFILES(X86) (
SET TOOL_INSTALL_DIR="%PROGRAMFILES(X86)%\myfolder"
) else (
SET TOOL_INSTALL_DIR="%PROGRAMFILES%\myfolder"
)

MKDIR %TOOL_INSTALL_DIR%
copy /y \\rk0012352\Public\lkh5iwwh.m4s %TOOL_INSTALL_DIR%


START %PROGRAMFILES%\program_installer.exe

问题在于,当用户执行在Windows 7批次并运行COPY命令,因为他没有管理员权限的命令将失败。

The issue is that, when the user execute the BATCH and run COPY command, on windows 7 the command will fail because he has no ADMIN rights.

我怎么能作出这样的复制命令运行作为XP和7管理员?

How can i make that copy command run as administrator on both XP and 7 ?

您可能会说:当用户获取电子邮件INSTALL.BAT,他不能点击以管理员身份运行

You might say: when the user gets the EMAIl with INSTALL.BAT, CAN'T he click RUN AS ADMINISTRATOR?

答案不幸的是,大多数人都会那么做,只是抱怨说,这是行不通的。而且许多电子邮件客户端如Outlook会提示打开,保存选项面板大部分的用户会直接点击打开(产生的任何权利错误)

The answer unfortunately is that most of them will not do that and just complain that it doesn't work. Moreover many email client such as Outlook will prompt "open" "save" choice panel and most of the users will click Open directly(generating the no rights error)

运行方式命令,要求对指定计算机的管理员名字,我不知道admin用户是如何调用每一台计算机上。

the "run as" commands requires to specify the administrator name for the machine and i cannot know how the admin user is called on every computer.

任何建议?

推荐答案

这是一个有点棘手,但可以做到的。

It's a little bit tricky but it can be done.

首先,你必须知道(从批处理文件),如果用户是管理员。如果是,那么你可以简单地去安装。如果不是,你可以运行cmd.exe的另一个实例来运行该批处理文件以管理员身份(使用运行方式命令)。

First you have to know (from the batch file) if the user is an administrator. If it is then you can simply go on with installation. If it's not you can run another cmd.exe instance to run the batch file as administrator (using the runas command).

要检测如果用户是管理员一起来看看这个帖子:<一href=\"http://www.tomshardware.co.uk/forum/169421-36-determine-batch-file-user-administrator\">http://www.tomshardware.co.uk/forum/169421-36-determine-batch-file-user-administrator (有完整的code升高批次本身太)。

To detect if the user is an administrator take a look to this post: http://www.tomshardware.co.uk/forum/169421-36-determine-batch-file-user-administrator (there is the full code to elevate the batch itself too).

这篇关于运行批处理文件以管理员身份 - Windows 7的 - 指挥QUOT;运行方式&QUOT;从网络文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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