home *** CD-ROM | disk | FTP | other *** search
/ Exploring Creation with P…al Science (2nd Edition) / Exploring Creation with Physical Science (2nd Edition).iso / exe / CreateShortcut.vbs next >
Encoding:
Text File  |  2012-12-18  |  2.2 KB  |  75 lines

  1. Option Explicit
  2.  
  3.     Dim fso
  4.     Dim ts
  5.     Dim strOPath
  6.     Dim strOExe
  7.     Dim strIndexPath
  8.     Dim strMPlayPath
  9.     Dim strOIni
  10.     Dim strSrcDrv
  11.     Dim strScriptPath
  12.     Dim wshShell
  13.     Dim strIconPath
  14.     Dim objShortcutLnk
  15.     Dim objShell
  16.     Dim strCrs
  17.     Dim objFolder
  18.     
  19.     Const APPLICATION_DATA = 28
  20.     Const FOF_CREATEPROGRESSDLG = &H0&
  21.     Const strReplacePath="C:\Documents and Settings\limited\Local Settings\Application Data\AEMCRS\"
  22.     
  23.     Set fso = CreateObject("Scripting.FileSystemObject")
  24.     Set objShell = CreateObject("Shell.Application")
  25.     Set wshShell = CreateObject("WScript.Shell")
  26.      
  27.     strScriptPath = Wscript.ScriptFullName
  28.     strOPath = objShell.NameSpace(APPLICATION_DATA).Self.Path
  29.     strSrcDrv = fso.GetParentFolderName(strScriptPath)
  30.     strSrcDrv = fso.GetParentFolderName(strSrcDrv)
  31.     strOPath = fso.BuildPath(strOPath, "\AEMCRS")
  32.     strOExe = fso.BuildPath(strOPath, "opera.exe")
  33.     strIndexPath = fso.BuildPath(strSrcDrv, "mm\index.html")
  34.     strMPlayPath = fso.BuildPath(strOPath, "mplayerc.exe")
  35.     strIconPath = fso.BuildPath(strOPath, "cd.ico")
  36.     strOIni = fso.BuildPath(strOPath, "profile\opera6.ini")
  37.  
  38.     Set ts = fso.OpenTextFile(fso.BuildPath(strSrcDrv, "discid.txt"))
  39.     ts.SkipLine
  40.     ts.SkipLine
  41.     strCrs = ts.ReadLine
  42.     ts.Close
  43.     
  44.     If fso.FolderExists(strOPath) Then
  45.         fso.DeleteFolder strOPath, True
  46.     End If
  47.     fso.CreateFolder (strOPath)
  48.     
  49.     Set objFolder = objShell.NameSpace(strOPath)
  50.     objFolder.CopyHere fso.BuildPath(strSrcDrv, "exe\bin\*.*")
  51.  
  52.     Set objShortcutLnk = wshShell.CreateShortcut(fso.BuildPath(wshShell.SpecialFolders("Desktop"), "AEM ") & strCrs & ".lnk")
  53.     objShortcutLnk.TargetPath = strOExe
  54.     objShortcutLnk.Arguments = Chr(34) & strIndexPath & Chr(34)
  55.     objShortcutLnk.WorkingDirectory = strOPath
  56.     objShortcutLnk.IconLocation = strIconPath
  57.     
  58.     objShortcutLnk.Save
  59.     
  60.     If fso.GetFile(strOIni).Attributes And 1 Then
  61.         fso.GetFile(strOIni).Attributes = fso.GetFile(strOIni).Attributes - 1
  62.     End If
  63.  
  64.     Set ts = fso.OpenTextFile(strOIni)
  65.     strCrs = ts.readall
  66.     ts.Close
  67.     
  68.     strCrs=Replace(strCrs,strReplacePath,strOPath & "\",1,-1,1)    
  69.     
  70.     Set ts = fso.OpenTextFile(strOIni,2)
  71.     ts.Write strCrs
  72.     ts.Close
  73.  
  74.     MsgBox "A shortcut to the course has been created on your desktop", vbInformation, "AEM Full Course CD"
  75.