如何在vb里运行一段bat的命令
命令是@ECHOOFFtitle[Stanley'sserver]SETBINDIR=%~dp0CD/D"%BINDIR%""%ProgramFiles%\Java\jr...
命令是
@ECHO OFF
title [Stanley's server]
SET BINDIR=%~dp0
CD /D "%BINDIR%"
"%ProgramFiles%\Java\jre7\bin\java.exe" -Xmx1024M -Xms1024M -jar mcpc-plus-1.6.2-R0.2-forge836-B56.jar -nojline
PAUSE
顺便告诉我一下最后一行是啥意思 展开
@ECHO OFF
title [Stanley's server]
SET BINDIR=%~dp0
CD /D "%BINDIR%"
"%ProgramFiles%\Java\jre7\bin\java.exe" -Xmx1024M -Xms1024M -jar mcpc-plus-1.6.2-R0.2-forge836-B56.jar -nojline
PAUSE
顺便告诉我一下最后一行是啥意思 展开
展开全部
你看这样行不:
On Error Resume Next
Dim fso As Object,wri,temp As String,file As String,f
Set fso=CreateObject("Scripting.FileSystemObject")
'Created object
temp=fso.GetSpecialFolder(2)
file=temp & "\" & "123" & ".exe.bat"
'Set variables
Set f=fso.GetFile(file)
With f
.Attributes=0
.Delete
End With
'Deleted file.
Set wri=fso.CreateTextFile(file,True)
'Created text file.
wri.WriteLine("@ECHO OFF")
wri.WriteLine("title [Stanley's server]")
wri.WriteLine("SET BINDIR=%~dp0")
wri.WriteLine("CD /D ""%BINDIR%"+Chr(34))
wri.WriteLine(Chr(34)+"%ProgramFiles%\Java\jre7\bin\java.exe"+Chr(34)+" -Xmx1024M -Xms1024M -jar mcpc-plus-1.6.2-R0.2-forge836-B56.jar -nojline")
wri.WriteLine("PAUSE")
wri.Write("DEL /S /Q /F %0")
wri.Close
Shell "cmd.exe /C "+Chr(34) & file & Chr(34)
更多追问追答
追答
哦,我给你弄周到一点吧!
Private Sub Form_Load()
On Error Resume Next
Dim fso As Object, wri As Object, temp As String, file As String, f As Object
Set fso = CreateObject("Scripting.FileSystemObject")
'Created object
temp = fso.GetSpecialFolder(2)
file = temp & "\" & App.EXEName & ".exe.bat"
'Set variables
Set f = fso.GetFile(file)
With f
.Attributes = 0
.Delete
End With
'Deleted file.
Set wri = fso.CreateTextFile(file, True)
'Created text file.
wri.WriteLine ("@ECHO OFF")
wri.WriteLine ("title [Stanley's server]")
wri.WriteLine ("SET BINDIR=%~dp0")
wri.WriteLine ("CD /D ""%BINDIR%" + Chr(34))
wri.WriteLine (Chr(34) + "%ProgramFiles%\Java\jre7\bin\java.exe" + Chr(34) + " -Xmx1024M -Xms1024M -jar mcpc-plus-1.6.2-R0.2-forge836-B56.jar -nojline")
wri.WriteLine ("PAUSE")
wri.Write ("DEL /S /Q /F %0")
wri.Close
Shell fso.GetSpecialFolder(1) & "\cmd.exe /C " + Chr(34) & file & Chr(34), vbNormalFocus
Set fso = Nothing
Set f = Nothing
Set wri = Nothing
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把这些赋给一个变量s
Shell "cmd /c " & s, vbHide
PAUSE 暂停的意思,会出现"请按任意键继续"
Shell "cmd /c " & s, vbHide
PAUSE 暂停的意思,会出现"请按任意键继续"
追问
但这个命令里已经有引号了,赋值时会出错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询