Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with WSH
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00514664
Message ID:
00514740
Views:
8
>George, I went with including an FPW. I was looking at trying to use the WshShell Environment object, it has a HomePath property, but it is read only, oh well. Thanks again,

John,

Glad to help. Before Gonz "got assimilated by the Borg" (read: went to work for Microsoft and this is day one of his "assimilation"< bg >). Right now I don't know if we're ever going to implement this one. I came up with the idea of a "Super Loader". This is designed to do two things that the original doesn't. First, it has the capability of automatically running the setup routine, based on the presence of a file having the same primary name as the executable with the extension "sup" on the network. Second, in the event of a user getting a new computer, it also detects (in most cases) whether or not an install needs to be done. It's not uncommon in my case for everything to be copied, including VFP programs, but the install not being run.
' Outline.vbs
' Generic Outline of new
' Program loader
' Filenames and paths based on Efficiency Reporter

Dim oShell, oFSO, cExe, cLocal, cRemote, cSetup, cStem, oRemote
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
cStem = "Eff_Rpts"
cExe = cStem & ".exe"
cSetup = cStem & ".sup"
cLocal = "C:\VFPLocal\"
cRemote = "I:\Foxwin\Launch\"
If NewerFile(cLocal & cSetup, cRemote & cSetup) Then
  ' Run the setup
  RunSetup cLocal & cSetup, cRemote & cStem
Else
  ' Check to make sure the install has been run
  If Not IsInstalled() Then
    ' Not installed
    RunSetup cLocal & cSetup, cRemote & cStem
  Else
    If NewerFile(cLocal & cExe, cRemote & cExe) Then
      oRemote = oFSO.GetFile cRemote & cExe
      oRemote.CopyFile cLocal
    End If
    oShell.Run(cLocal & cExe & cParameters)
  End If
End If

Private Function NewerFile(tcLocalFile, tcRemoteFile)
  ' Determines if the local file is older than the remote
  ' Returns True if local file doesn't exist
  ' Returns False if remote doesn't exist

  Dim oFSO, oLocal, oRemote
  Set oFSO = CreateObject("Scripting.FileSystemObject")
  If Not oFSO.FileExists(tcLocalFile) Then
    NewerFile = True
  Else
    If Not oFSO.FileExists(tcRemoteFile) Then
      NewerFile = False
    Else
      oLocal = oFSO.GetFile(tcLocalFile)
      oRemote = oFSO.Getfile(tcRemoteFile)
      NewerFile = (oRemote.DateLastModified > oLocal.DateLastModified)
    End if
  End If
End Function

Private Sub RunSetup(tcTextFile, tcRemotePath)
  ' Creates a new setup text file and then runs the setup program

  Dim oFSO, oShell, oTest
  Set oFSO = CreateObject("Scripting.FileSystemObject")
  Set oShell = CreateObject("WScript.Shell")
  ' Write File
  Set oText = oFSO.CreateTextFile(tcTextFile, True)
  oText.Close
  ' Run setup
  oShell.Run(tcRemotePath & "\Setup.exe /Q")
End Sub

Private Function IsInstalled
  
  Dim oShell, cKey, cValue
  Set oShell = CreateObject("WScript.Shell")
  cKey = "HKCR\VisualFoxPro.Runtime\CLSID\"
  On Error Resume Next
  cValue = oShell.RegRead(cKey)
  IsInstalled = (cValue > "")
End Function
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform