1. Home
  2. Docs
  3. Scense Embedded Scripting...
  4. Scense Scripting Examples
  5. Applications

Applications

Sample script for handling applications.

Start application from application context driveletter

This script will start an application from a drive letter, while still complying with the application contexts as defined by the administrator.
This script uses the ‘Process’ service.

Sub Scense_Main()
    Dim FinalDrive
    Dim ApprovalDrive
    Dim TestDrive
    Dim EffectiveDrive

    Dim tStart
    Dim tStartIn

    Dim ShowWindow

    Dim tInstallLocation

'--------------------------------------------------------------------------
    'Please complete the required variables

    'Initialize Program locations
    tStart = "<\DIR\APP.EXE>"   '<-- Insert programpath, the path(or EXE if
                                     no path) should start with a slash!
    tStartIn = "<\DIR>"         '<-- Insert programfolder, the path should 
                                     start with a slash!

    'Initialize Customer Application DriveLetters
    FinalDrive = "P"            '<-- Insert DriveLetter for the Final 
    ApprovalDrive = "R"         '<-- Insert DriveLetter for the Approval 
    TestDrive = "T"             '<-- Insert DriveLetter for the test Context

    'Overrule Local Application DriveLetter
    LocalDrive = ""             '<-- Insert DriveLetter for Local install,
                                     leave blank to use default

    'Specifics
    ShowWindow = 1              '<-- Insert a value (0=Hidden, 1=Normal, 
                                     2=Minimized, 3=Maximized)
'--------------------------------------------------------------------------

    '-- Check Install type -----------------------------------------------
    If ReplaceVariables("%InstallType%") = "Shared" Then
        'Shared Installation: Check Application Context
        Select Case ReplaceVariables("%TaskSetStatus%")
	    Case 0 'Final
                EffectiveDrive = FinalDrive
            Case 1 'Approval
                EffectiveDrive = ApprovalDrive
            Case 2 'Test
                EffectiveDrive = TestDrive
        End Select

        'Compose the start parameters
        tStart = """" & EffectiveDrive & ":" & tStart & """"
        tstartIn = EffectiveDrive & ":" & tStartIn

    Else
        'Local Installation
        If LocalDrive = "" Then
            'Retrieve the Default
            tInstallLocation = ReplaceVariables("%InstallLocation%")
        Else
            tInstallLocation = LocalDrive & ":"
        End If

        'Compose the start parameters
        tStart = """" & tInstallLocation & tStart & """"
        tstartIn = tInstallLocation & tStartIn
    End If  

    '-- Start the process -------------------------------------------------
    With Process  
        'ScenseLog Feedback 
        WriteScenseLog "Start: " & tstart
        WriteScenseLog "In   : " & tStartIn

        'Start the process
        .StartIn = tstartIn
        .ShowWindow = ShowWindow
        If Not .StartProcess(tStart) Then
            'report the error
            Err.Raise .ReturnCode
        End If
    End With
End Sub