0

我无法打开 vbs 文件,我想用于 microsoft office 2013

Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="qemu\qemu.cmd"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write "@ECHO OFF" & vbCrLf
objFile.Write "pushd ""%~dp0""" & vbCrLf
objFile.Write "rem cd qemu" & vbCrLf
objFile.Write "start qemu.exe ^" & vbCrLf
objFile.Write "-smbios type=1,manufacturer=Intel,version=1.01234,uuid=564d81c6-cd3a-                        d8e4-db29-756df139acb9 ^" & vbCrLf
objFile.Write "-uuid 564d81c6-cd3a-d8e4-db29-756df139acb9 ^" & vbCrLf
objFile.Write "-net nic,vlan=0 -net user,vlan=0 -redir tcp:1688::1688 ^" & vbCrLf
objFile.Write "-m 350 ^" & vbCrLf
objFile.Write "-hda Bios\kmsm4WOen.rom ^" & vbCrLf
objFile.Write ("-rtc base=" & Year(Now) & "-" & Month(Now) & "-" & Day(Now) & "T" &     Hour(Now) & ":" & Minute (Now) & ":" & Second (Now) & ",clock=host ^") & vbCrLf
objFile.Write "-name ""KMSmicro v4.0.WO-En IP-127.0.0.1-254:1688"" ^" & vbCrLf
objFile.Write "-M pc ^" & vbCrLf
objFile.Write "-L Bios" & vbCrLf
objFile.Write "popd" & vbCrLf
objFile.Write "exit" & vbCrLf
objFile.Close
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run ("qemu\qemu.cmd",,True)
Set obj = CreateObject("Scripting.FileSystemObject")
obj.DeleteFile(outfile)    

我所有的vbs文件我都无法打开它请告诉我如何修复我,谢谢。

4

1 回答 1

0

第 3 行的错误“800a004c - Path not found”被抛出,因为子文件夹qemu不存在。.CreateTextFile()将创建一个文件,但不会创建文件路径中的文件夹。

PS:

由于.CreateTextFile().Run()使用相对路径,在qemu某处“拥有”一个文件夹将无济于事。它必须是当前目录的子文件夹。避免此问题的最佳方法是使用绝对/硬编码路径。

outFile="a:\b\c d\qemu\qemu.cmd"
Set objFile = objFSO.CreateTextFile(outFile,True)
...
outFile = """" & outFile & """"
Return = WshShell.Run (outFile,,True)
于 2013-02-22T07:49:31.927 回答