创建vbs脚本以将.bat文件安装到远程IP

时间:2022-10-16 07:28:34

I have a .bat file that i need run on remote IP's on our network. What i would like to do is prompt for the 10.x.x portion of the IP address, then have the script preform a loop which starts at .1 and continues to .254, that way the .bat file is pushed to 10.x.x.1 - 10.x.x.254

我有一个.bat文件,我需要在我们的网络上的远程IP上运行。我想要做的是提示IP地址的10.xx部分,然后让脚本预先形成一个循环,从.1开始并继续到.254,这样.bat文件被推送到10.xx1 - 10.xx254

So far this is what ive got:

到目前为止,这是我得到的:

Dim WshShell
set WshShell = CreateObject("wscript.shell")

strUserInput = InputBox("enter network" )

Wshshell.exec("cmd /k CD ../directory/file.bat" & strUserInput)

If i manually open up a cmd and navigate to the correct directory and run file.bat 10.x.x.x, the .bat file will run on the remote machine if its on the network.

如果我手动打开cmd并导航到正确的目录并运行file.bat 10.x.x.x,则.bat文件将在远程计算机上运行(如果它在网络上)。

1 个解决方案

#1


0  

This worked for creating and showing the string correctly:

这适用于正确创建和显示字符串:

Sub test()
    Dim location As String
    location = InputBox("enter network")
    MsgBox ("cmd /k CD ../directory/file.bat" & location)
End Sub

#1


0  

This worked for creating and showing the string correctly:

这适用于正确创建和显示字符串:

Sub test()
    Dim location As String
    location = InputBox("enter network")
    MsgBox ("cmd /k CD ../directory/file.bat" & location)
End Sub