0
我想启动一个exe文件,它是使用vbscript的特殊文件夹中的一个消息箱,但我什么也没得到。这是我的代码vbscript从特殊文件夹启动一个exe文件
option explicit
dim shellobj,startup,objShell,objFolder,filesystemobj,installdir,installname
set shellobj = wscript.createobject("wscript.shell")
set filesystemobj = createobject("scripting.filesystemobject")
Set objShell = CreateObject("Shell.Application")
installdir = "%appdata%\Microsoft"
installname = wscript.scriptname
filesystemobj.copyfile wscript.scriptfullname,installdir & installname,true
startup = shellobj.specialfolders("%appdata%\Microsoft") &"\msg.exe"
if filesystemobj.fileexists(startup) Then
shellobj.run "wscript.exe //B " & chr(34) & startup & chr(34)
Wscript.Quit
end if
感谢你的回答。我用下面的代码解决了它:Dim WSHShell,AppData,objWshShl,objFSO Set objFSO = CreateObject(“Scripting.FileSystemObject”) Set WSHShell = WScript.CreateObject(“WScript.Shell”) Set objWshShl = WScript.CreateObject(“ WScript.Shell “) 应用程序数据= objWshShl.SpecialFolders(” 应用程序数据“)& ”\微软\ msg.exe“ 如果objFSO.FileExists(应用程序数据)然后 组oExec = WshShell.Exec(应用程序数据) WScript.Quit \t其他 \t WScript.echo“找不到文件” \t结束时,如果 – user2842276
不客气。如果解决了您的问题,请考虑[接受答案](http://meta.stackexchange.com/a/5235)。另外,请避免在评论中张贴代码,因为它往往变得不可读。 –