Need help to create correct batch file as per this code
PHP Code:
Private Sub deleteOLD()
'create the batch file in the same directory as the old and new versions to make this batch smaller
Open App.Path & IIf(Right(App.Path, 1) <> "\", "\DeleteOLD.bat", "DeleteOLD.bat") For Output As #1 'create the batch file
'open the created batch file and print some commands into it, batch file will look like this
'@Echo off
':S
'Del "(this is the app exe name, we use this incase the user changed the exe name)" <note: the quotation marks throughout this batch file are nesasary incase your exe name contains spaces>
'If Exist "(app name again here)" Goto S <so if its not deleted yet, go back to :S and read on>
':D
'ren "Update ExampleNEW.exe" "Update Example.exe" <use the batch to change the new version into the same name as the old version>
'If Exist "Update ExampleNEW.exe" Goto D <same as three lines above>
'Update Example <run the new version, name is now the same as old version>
'Del DeleteOLD.bat <delete this batch file>
Print #1, "@Echo off" & vbCrLf & _
":S" & vbCrLf & _
"Del " & Chr(34) & App.EXEName & ".exe" & Chr(34) & vbCrLf & _
"If Exist " & Chr(34) & App.EXEName & ".exe" & Chr(34) & " Goto S" & vbCrLf & _
":D" & vbCrLf & _
"ren " & Chr(34) & "Update ExampleNEW.exe" & Chr(34) & " " & Chr(34) & "Update Example.exe" & Chr(34) & vbCrLf & _
"If Exist " & Chr(34) & "Update ExampleNEW.exe" & Chr(34) & " Goto D" & vbCrLf & _
Chr(34) & "Update Example.exe" & Chr(34) & vbCrLf & "Del DeleteOLD.bat"
Close #1
'run the batch file, make it run hidden
Shell "DeleteOLD.bat", vbHide
End
End Sub