Guest User

HTA2

a guest
Jun 30th, 2015
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 9.78 KB | None | 0 0
  1. <!doctype html>
  2.  
  3. <html lang="en">
  4.     <head>
  5.  
  6.         <!--[if lt IE 9]>
  7.         <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  8.         <![endif]-->
  9.    
  10.         <script language="VBScript">
  11.  
  12.             Window.ResizeTo 1200,700
  13.             WinWidth = 1200
  14.             WinHeight = 700
  15.  
  16.             Sub CenterWindow( widthX, heightY )
  17.                 Window.MoveTo (screen.Width - widthX)/2, (screen.Height - heightY)/3
  18.             End Sub
  19.            
  20.             CenterWindow WinWidth, WinHeight
  21.            
  22.         </script>
  23.    
  24.         <title> PortableFL Launcher</title>
  25.         <HTA:APPLICATION
  26.         ApplicationName="PortableFL Launcher"
  27.         Border="Thin"
  28.         BorderStyle="Raised"
  29.         Caption="Yes"
  30.         ContextMenu="No"
  31.         Icon="AppData/Launcher/FL.ico"
  32.         ID="Launcher"
  33.         MaximizeButton="No"
  34.         MinimizeButton="No"
  35.         ShowInTaskbar="Yes"
  36.         SingleInstance="Yes"
  37.         SysMenu="Yes"
  38.         WindowState="Normal"
  39.         InnerBorder="No"
  40.         Navigable="Yes"
  41.         Scroll="no"
  42.         ScrollFlat="yes"
  43.         Selection="No"
  44.         Version="1.0"
  45.         />
  46.  
  47.         <meta charset="utf-8">
  48.         <meta name="description" content="PortableFL Launcher">
  49.         <meta name="author" content="Zyos">
  50.  
  51.         <link rel="stylesheet" href="AppData/Launcher/styles.css?v=1.0">
  52.            
  53.     </head>
  54.  
  55. <script language='VBScript'>
  56.    
  57.     Set objShell = CreateObject("WScript.Shell")
  58.     Set fsObject = CreateObject("Scripting.FileSystemObject")
  59.  
  60.     '-- Set custom variables.
  61.     OsType = objShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
  62.     ImportPathX64 = objShell.ExpandEnvironmentStrings("%PROGRAMFILES(X86)%")
  63.     ImportPathX86 = objShell.ExpandEnvironmentStrings("%PROGRAMFILES%")
  64.     GamePath = "Microsoft Games\Freelancer\EXE"
  65.     AppPath = objShell.CurrentDirectory
  66.    
  67.    
  68.     Function ReadIni( myFilePath, mySection, myKey )
  69.     ' This function returns a value read from an INI file
  70.     '
  71.     ' Arguments:
  72.     ' myFilePath  [string]  the (path and) file name of the INI file
  73.     ' mySection   [string]  the section in the INI file to be searched
  74.     ' myKey       [string]  the key whose value is to be returned
  75.     '
  76.     ' Returns:
  77.     ' the [string] value for the specified key in the specified section
  78.     '
  79.     ' CAVEAT:     Will return a space if key exists but value is blank
  80.     '
  81.     ' Written by Keith Lacelle
  82.     ' Modified by Denis St-Pierre and Rob van der Woude
  83.  
  84.     Const ForReading   = 1
  85.     Const ForWriting   = 2
  86.     Const ForAppending = 8
  87.  
  88.     Dim intEqualPos
  89.     Dim objFSO, objIniFile
  90.     Dim strFilePath, strKey, strLeftString, strLine, strSection
  91.  
  92.     Set objFSO = CreateObject( "Scripting.FileSystemObject" )
  93.  
  94.     ReadIni     = ""
  95.     strFilePath = Trim( myFilePath )
  96.     strSection  = Trim( mySection )
  97.     strKey      = Trim( myKey )
  98.  
  99.     If objFSO.FileExists( strFilePath ) Then
  100.         Set objIniFile = objFSO.OpenTextFile( strFilePath, ForReading, False )
  101.         Do While objIniFile.AtEndOfStream = False
  102.             strLine = Trim( objIniFile.ReadLine )
  103.  
  104.             ' Check if section is found in the current line
  105.             If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then
  106.                strLine = Trim( objIniFile.ReadLine )
  107.  
  108.                ' Parse lines until the next section is reached
  109.                Do While Left( strLine, 1 ) <> "["
  110.                    ' Find position of equal sign in the line
  111.                    intEqualPos = InStr( 1, strLine, "=", 1 )
  112.                    If intEqualPos > 0 Then
  113.                        strLeftString = Trim( Left( strLine, intEqualPos - 1 ) )
  114.                        ' Check if item is found in the current line
  115.                        If LCase( strLeftString ) = LCase( strKey ) Then
  116.                            ReadIni = Trim( Mid( strLine, intEqualPos + 1 ) )
  117.                            ' In case the item exists but value is blank
  118.                            If ReadIni = "" Then
  119.                                ReadIni = " "
  120.                            End If
  121.                            ' Abort loop when item is found
  122.                            Exit Do
  123.                        End If
  124.                    End If
  125.  
  126.                    ' Abort if the end of the INI file is reached
  127.                    If objIniFile.AtEndOfStream Then Exit Do
  128.  
  129.                    ' Continue with next line
  130.                    strLine = Trim( objIniFile.ReadLine )
  131.                Loop
  132.            Exit Do
  133.            End If
  134.        Loop
  135.        objIniFile.Close
  136.    Else
  137.        
  138.        End If
  139. End Function
  140.  
  141.  
  142. Sub WriteIni( myFilePath, mySection, myKey, myValue )
  143.    ' This subroutine writes a value to an INI file
  144.    '
  145.    ' Arguments:
  146.    ' myFilePath  [string]  the (path and) file name of the INI file
  147.    ' mySection   [string]  the section in the INI file to be searched
  148.    ' myKey       [string]  the key whose value is to be written
  149.    ' myValue     [string]  the value to be written (myKey will be
  150.    '                       deleted if myValue is <DELETE_THIS_VALUE>)
  151.    '
  152.    ' Returns:
  153.    ' N/A
  154.    '
  155.    ' CAVEAT:     WriteIni function needs ReadIni function to run
  156.    '
  157.    ' Written by Keith Lacelle
  158.    ' Modified by Denis St-Pierre, Johan Pol and Rob van der Woude
  159.  
  160.    Const ForReading   = 1
  161.    Const ForWriting   = 2
  162.    Const ForAppending = 8
  163.  
  164.    Dim blnInSection, blnKeyExists, blnSectionExists, blnWritten
  165.    Dim intEqualPos
  166.    Dim objFSO, objNewIni, objOrgIni, wshShell
  167.    Dim strFilePath, strFolderPath, strKey, strLeftString
  168.    Dim strLine, strSection, strTempDir, strTempFile, strValue
  169.  
  170.    strFilePath = Trim( myFilePath )
  171.    strSection  = Trim( mySection )
  172.    strKey      = Trim( myKey )
  173.    strValue    = Trim( myValue )
  174.  
  175.    Set objFSO   = CreateObject( "Scripting.FileSystemObject" )
  176.    Set wshShell = CreateObject( "WScript.Shell" )
  177.  
  178.    strTempDir  = wshShell.ExpandEnvironmentStrings( "%TEMP%" )
  179.    strTempFile = objFSO.BuildPath( strTempDir, objFSO.GetTempName )
  180.  
  181.    Set objOrgIni = objFSO.OpenTextFile( strFilePath, ForReading, True )
  182.    Set objNewIni = objFSO.CreateTextFile( strTempFile, False, False )
  183.  
  184.    blnInSection     = False
  185.    blnSectionExists = False
  186.    ' Check if the specified key already exists
  187.    blnKeyExists     = ( ReadIni( strFilePath, strSection, strKey ) <> "" )
  188.    blnWritten       = False
  189.  
  190.    ' Check if path to INI file exists, quit if not
  191.    strFolderPath = Mid( strFilePath, 1, InStrRev( strFilePath, "\" ) )
  192.    If Not objFSO.FolderExists ( strFolderPath ) Then
  193.        
  194.        Set objOrgIni = Nothing
  195.        Set objNewIni = Nothing
  196.        Set objFSO    = Nothing
  197.        
  198.    End If
  199.  
  200.    While objOrgIni.AtEndOfStream = False
  201.        strLine = Trim( objOrgIni.ReadLine )
  202.        If blnWritten = False Then
  203.            If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then
  204.                blnSectionExists = True
  205.                blnInSection = True
  206.            ElseIf InStr( strLine, "[" ) = 1 Then
  207.                blnInSection = False
  208.            End If
  209.        End If
  210.  
  211.        If blnInSection Then
  212.            If blnKeyExists Then
  213.                intEqualPos = InStr( 1, strLine, "=", vbTextCompare )
  214.                If intEqualPos > 0 Then
  215.                    strLeftString = Trim( Left( strLine, intEqualPos - 1 ) )
  216.                    If LCase( strLeftString ) = LCase( strKey ) Then
  217.                        ' Only write the key if the value isn't empty
  218.                        ' Modification by Johan Pol
  219.                        If strValue <> "<DELETE_THIS_VALUE>" Then
  220.                            objNewIni.WriteLine strKey & "=" & strValue
  221.                        End If
  222.                        blnWritten   = True
  223.                        blnInSection = False
  224.                    End If
  225.                End If
  226.                If Not blnWritten Then
  227.                    objNewIni.WriteLine strLine
  228.                End If
  229.            Else
  230.                objNewIni.WriteLine strLine
  231.                    ' Only write the key if the value isn't empty
  232.                    ' Modification by Johan Pol
  233.                    If strValue <> "<DELETE_THIS_VALUE>" Then
  234.                        objNewIni.WriteLine strKey & "=" & strValue
  235.                    End If
  236.                blnWritten   = True
  237.                blnInSection = False
  238.            End If
  239.        Else
  240.            objNewIni.WriteLine strLine
  241.        End If
  242.    Wend
  243.  
  244.    If blnSectionExists = False Then ' section doesn't exist
  245.        objNewIni.WriteLine
  246.        objNewIni.WriteLine "[" & strSection & "]"
  247.            ' Only write the key if the value isn't empty
  248.            ' Modification by Johan Pol
  249.            If strValue <> "<DELETE_THIS_VALUE>" Then
  250.                objNewIni.WriteLine strKey & "=" & strValue
  251.            End If
  252.    End If
  253.  
  254.    objOrgIni.Close
  255.    objNewIni.Close
  256.  
  257.    ' Delete old INI file
  258.    objFSO.DeleteFile strFilePath, True
  259.    ' Rename new INI file
  260.    objFSO.MoveFile strTempFile, strFilePath
  261.  
  262.    Set objOrgIni = Nothing
  263.    Set objNewIni = Nothing
  264.    Set objFSO    = Nothing
  265.    Set wshShell  = Nothing
  266. End Sub
  267.  
  268.     WriteIni "config.ini", "bgAudio", "AutoPlay", "True"
  269.    
  270. </script>
  271.  
  272. <body bgcolor="#FAFAFA">
  273.     <div class='launcher'>
  274.  
  275.         <div class='button'>
  276.        
  277.             <script language="VBScript">
  278.  
  279.                 If fsObject.FileExists("" & AppPath & "\" & GamePath & "\Freelancer.exe") Then
  280.                     ' Show play button
  281.                     Document.Write("<input class='button' type='button' value='Play' name='run_button' onClick='Play'><p>")
  282.  
  283.                 ElseIf fsObject.FolderExists("" & ImportPathX86 & "\" & GamePath & "") Then
  284.                     ' Show install button
  285.                     Document.Write("<input class='button' type='button' value='Install' name='run_button' onClick='Install'><p>")
  286.    
  287.                 Else
  288.                     '-- Throw up a message to inform the user that Freelancer is not installed.
  289.                     Document.Write("<input class='button' type='button' value='Error' name='run_button' onClick=''><p>")
  290.                 End If
  291.             </script>
  292.        
  293.         </div>
  294.  
  295.     </div>
  296.    
  297. </body>
  298. </html>
Advertisement
Add Comment
Please, Sign In to add comment