DOS 批量编程 pSEXEC
我有一个批处理文件,比如 A.bat 执行时,这个 A.bat 将创建另一个批处理文件,例如remote.bat,
如果我手动将remote.bat复制到远程计算机,那么它可以100%完美地工作。但是,如果我将它用作 A.bat 中 psExec 的一部分,那么它根本不起作用。然而,我的 A.bat 在执行时说..
Connecting to ABCDEF machine
Starting PsExec Server on ABCDEF machine
Copying C:\remote.bat on ABCDEF machine
Started C:\remote.bat ABCDEF machine with Process Id XXXX
但是,在我看来,remote.bat 文件根本没有执行。
我在remote.bat 中的内容是..
net use \\DIR1\DIR2 password /user:Administrator
XCOPY \\DIR1\DIR2\DIR3\DIR4\* c:\DIR3\DIR4\ /E
我根本没有看到在远程计算机的C: 下创建DIR3\DIR4。但是,如果我手动复制remote.bat并在远程计算机中执行它,它就会起作用。
我用来调用 PsExec 的命令是
psexec \\MachineName -u Administrator -p pasword -d -c -f c:\remote.bat
Any suggest?请?
I have a batch file, say A.bat
On execution, this A.bat will create another batch file, say remote.bat
If I manually copy the remote.bat to the remote machine then it works 100% perfect. However, if I use it as a part of psExec in my A.bat then it does not work at all. However, my A.bat while executing says..
Connecting to ABCDEF machine
Starting PsExec Server on ABCDEF machine
Copying C:\remote.bat on ABCDEF machine
Started C:\remote.bat ABCDEF machine with Process Id XXXX
However, it looks to me that the remote.bat file is not executed at all.
What I have inside remote.bat is..
net use \\DIR1\DIR2 password /user:Administrator
XCOPY \\DIR1\DIR2\DIR3\DIR4\* c:\DIR3\DIR4\ /E
I do not see the DIR3\DIR4 getting created under C: of my remote machine at all. However, it works if I manually copy the remote.bat and execute it in my remote machine.
The command I use to call PsExec is
psexec \\MachineName -u Administrator -p pasword -d -c -f c:\remote.bat
Any advice? please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
BAT 文件与 CMD 的关联位于您的本地用户配置文件中。我不确定 Shell 如何准确处理它,但在远程目标上调用 psexec 不会调用 cmd 来运行批处理文件。
将
cmd.exe /c
放在remote.bat
前面,如下所示:但是您必须首先获取文件 remote.bat。整个事情看起来像这样:
The association of BAT files with CMD is in your local user profile. I'm not shure how the Shell handles it exactly, but calling psexec on a remote target won't invoke cmd to run your batch file.
Put
cmd.exe /c
in front ofremote.bat
like this instead :But you must get the file remote.bat across first. The whole thing would look like this :