从 NSIS 执行命令行命令 [英] Execute Command-Line Command from NSIS

查看:614
本文介绍了从 NSIS 执行命令行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建我的第一个 NSI 脚本,我只是想知道我是否可以从 NSIS 执行命令行命令,还是应该只执行批处理文件?我真的不知道从哪里开始,其他类似的话题也让我有点不知所措.

解决方案

我建议您查看 nsExec 插件.我最近遇到了一种情况,我需要从 NSIS 脚本内部 ping 服务器,以下代码对我来说非常适合.

nsExec::Exec '"C:\Windows\System32\PING.EXE" $URL'

使用 nsExec 的好处是它执行命令时不会在屏幕上弹出 dos 框.返回值被压入堆栈,您也可以通过几种不同的方式访问程序的输出(如果存在).

我在 NSIS 网站上找不到关于该插件的大量信息,但以下链接应该可以帮助您朝着正确的方向开始:

http://nsis.sourceforge.net/Docs/nsExec/nsExec.txt>

我注意到您专门询问了一个 COPY 命令,它是一个内部 DOS 命令,这意味着您将无法像我使用 ping 那样执行它.我可能弄错了,但您不需要使用任何外部程序来执行这样的基本命令.您应该能够使用 NSIS 命令复制大部分内部命令.

例如复制一个文件(或多个文件)使用 NSIS 命令:CopyFiles

NSIS 脚本参考是您的朋友:)(ctrl+f 也是)

I'm creating my first NSI script and I'm just wondering if I can execute a command-line command from NSIS or should I just execute a batch file? I don't really know where to begin and other similar topics have gone a little over my head.

解决方案

I would recommend taking a look at the nsExec plugin. I just recently had a situation where I needed to ping a server from inside an NSIS script, and the following code worked perfectly for me.

nsExec::Exec '"C:\Windows\System32\PING.EXE" $URL'

The benefit of using nsExec is that it executes the command without making a dos box pop up on your screen. The return value is pushed onto the stack, and there are a couple different ways that you can access the output of the program as well (if any exists).

There isn't a whole lot of information about the plugin on the NSIS website that I could find, but the following link should get you started in the right direction:

http://nsis.sourceforge.net/Docs/nsExec/nsExec.txt

Edit:

I noticed you asked specifically about a COPY command which is an internal DOS command, meaning that you won't be able to execute it like I did with ping. I may be mistaken but you shouldn't need to use any outside programs to carry out basic commands like this. You should be able to replicate most of the internal commands using NSIS commands.

For Example to copy a file (or multiple files) use the NSIS command: CopyFiles

The NSIS Scripting Reference is your friend :) (So is ctrl+f)

这篇关于从 NSIS 执行命令行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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