home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 221 - Disc 1 / DPCS0706.ISO / In The Mag / Programming Expert / HomeRotator.exe / HomeRotator / Setup.vbs < prev    next >
Encoding:
Text File  |  2006-04-12  |  2.1 KB  |  90 lines

  1. button=Msgbox("You are about to setup Home Page Rotator - click OK to continue or Cancel to abort",1)
  2. if button = 1 then 
  3.  Setup
  4.     Msgbox "setup complete"
  5. else
  6.  msgbox "Setup cancelled - run setup again to install or refresh an installation"
  7. end if
  8.  
  9. Sub Setup
  10. 'create folders and copy files
  11.  
  12. 'create standard objects
  13. Set WshShell = WScript.CreateObject("WScript.Shell")
  14. set fso=CreateObject("Scripting.FileSystemObject")
  15.  
  16. 'Get folder names
  17. Set WshSysEnv = WshShell.Environment("PROCESS")
  18. ProgFolder=WshSysEnv("ProgramFiles")
  19. ProgFolder =ProgFolder & "\HomePageRotator"
  20.  
  21. Set WshSysEnv = WshShell.Environment("PROCESS")
  22. Sys32=WshSysEnv("SystemRoot") & "\System32"
  23.  
  24. currentdir= WshShell.currentdirectory
  25.  
  26. 'Create project folder
  27. if not(fso.folderexists(ProgFolder)) then
  28.  fso.createfolder(ProgFolder)
  29. end if
  30.  
  31. 'Copy project files
  32. fso.copyfile currentdir & "\HR.htm",ProgFolder & "\",true
  33. fso.copyfile currentdir & "\rotate.vbs",Sys32 & "\",true
  34.  
  35. 'Setup registry for right click in IE
  36. ProgURL="file://" & ProgFolder & "\HR.htm"
  37. MenuItem="Add page to home page rotation"
  38. WshShell.RegWrite _
  39.  "HKCU\Software\Microsoft\Internet Explorer\MenuExt\" _
  40.  & Menuitem & "\",_
  41.  ProgURL, "REG_SZ"
  42.  
  43. 'Set the schedule
  44.  
  45. 'Get the user name and pass word
  46. Set Net = CreateObject("WScript.Network")
  47. User = Net.UserName
  48. pass=InputBox( "Enter your password", "Password")
  49.  
  50.  
  51. 'Delete existing task if any
  52. cmdline ="schtasks /delete /tn ""Home Page Rotate"" /f"
  53. set sched=wshShell.exec(cmdline)
  54. do while sched.status=0
  55.  wscript.sleep 100
  56. loop
  57.  
  58.  
  59. ' Create the new task
  60. cmdline="schtasks /create /tn ""Home Page Rotate"""
  61. cmdline=cmdline & " /tr rotate.vbs "  
  62. cmdline=cmdline & " /sc minute /mo 20 /ru " & chr(34) & User & chr(34) & " /rp " & chr(34) & pass & chr(34)
  63.  
  64. set sched=wshShell.exec(cmdline)
  65.  
  66. ' Handle messages from schtasks
  67. wscript.sleep 100
  68. input1 = sched.Stderr.ReadAll
  69. input2 = sched.StdOut.ReadAll
  70.         
  71. 'Show the results
  72. if input2<>"" then
  73. msgbox input2
  74. end if          
  75. if input1<>"" Then
  76. msgbox input1
  77. end if
  78.  
  79. end sub
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.