2012. 9. 5. 14:42
#Include <Array.au3>
#Include <File.au3>
; Check if Mozilla Firefox x86 version is installed
If @OSArch = "X86" Then
$MozillaFirefoxCurrentVersion = RegRead("HKLM\SOFTWARE\Mozilla\Mozilla Firefox", "CurrentVersion")
$MozillaFirefoxInstallDirectory = RegRead("HKLM\SOFTWARE\Mozilla\Mozilla Firefox\" & $MozillaFirefoxCurrentVersion & "\Main", "Install Directory")
EndIf
If @OSArch = "X64" Then
$MozillaFirefoxCurrentVersion = RegRead("HKLM\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox", "CurrentVersion")
$MozillaFirefoxInstallDirectory = RegRead("HKLM\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\" & $MozillaFirefoxCurrentVersion & "\Main", "Install Directory")
EndIf
$MozillaFirefoxExecutableFile = FileExists($MozillaFirefoxInstallDirectory & "\firefox.exe")
If $MozillaFirefoxExecutableFile = 0 Then
MsgBox(0x40010, @ScriptName, "Mozilla Firefox is not installed! Please install it and then run this script!", 4)
Exit
EndIf
; Find Mozilla Firefox profile folder
If FileExists(@AppDataDir & "\Mozilla\Firefox\profiles.ini") Then
$Mozilla_Firefox_profile_folder = IniRead(@AppDataDir & "\Mozilla\Firefox\profiles.ini", "Profile0", "Path", "")
$Mozilla_Firefox_profile_folder = StringReplace($Mozilla_Firefox_profile_folder, "/", "\")
EndIf
; EDIT MOZILLA FIREFOX PREFERENCES FILE
$InputFile = @AppDataDir & "\Mozilla\Firefox\" & $Mozilla_Firefox_profile_folder & "\prefs.js"
; String to find
$StringToFind = '"browser.startup.homepage"'
; New home page address
$HomePageAddress = "" ; write the desired home page address (inside quotes), for example: http://www.google.com/
; Delete the current home page address
Global $Array
_FileReadToArray ($InputFile, $Array)
$Array = _DeleteHomePageAddress ($Array, $StringToFind)
_FileWriteFromArray ($InputFile, $Array, 1)
; Write a new home page address
$File = FileOpen($InputFile, 257) ; UTF8 encoding without BOM
FileWriteLine($File, 'user_pref("browser.startup.homepage", ' & '"' & $HomePageAddress & '"' & ');')
FileClose($File)
Func _DeleteHomePageAddress ($Array, $StringToFind)
Local $Item
For $Element In $Array
If StringInstr ($Element, $StringToFind) <> 0 Then
_ArrayDelete ($Array, $Item)
Else
$Item+=1
EndIf
Next
Return ($Array)
EndFunc
#Include <File.au3>
; Check if Mozilla Firefox x86 version is installed
If @OSArch = "X86" Then
$MozillaFirefoxCurrentVersion = RegRead("HKLM\SOFTWARE\Mozilla\Mozilla Firefox", "CurrentVersion")
$MozillaFirefoxInstallDirectory = RegRead("HKLM\SOFTWARE\Mozilla\Mozilla Firefox\" & $MozillaFirefoxCurrentVersion & "\Main", "Install Directory")
EndIf
If @OSArch = "X64" Then
$MozillaFirefoxCurrentVersion = RegRead("HKLM\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox", "CurrentVersion")
$MozillaFirefoxInstallDirectory = RegRead("HKLM\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox\" & $MozillaFirefoxCurrentVersion & "\Main", "Install Directory")
EndIf
$MozillaFirefoxExecutableFile = FileExists($MozillaFirefoxInstallDirectory & "\firefox.exe")
If $MozillaFirefoxExecutableFile = 0 Then
MsgBox(0x40010, @ScriptName, "Mozilla Firefox is not installed! Please install it and then run this script!", 4)
Exit
EndIf
; Find Mozilla Firefox profile folder
If FileExists(@AppDataDir & "\Mozilla\Firefox\profiles.ini") Then
$Mozilla_Firefox_profile_folder = IniRead(@AppDataDir & "\Mozilla\Firefox\profiles.ini", "Profile0", "Path", "")
$Mozilla_Firefox_profile_folder = StringReplace($Mozilla_Firefox_profile_folder, "/", "\")
EndIf
; EDIT MOZILLA FIREFOX PREFERENCES FILE
$InputFile = @AppDataDir & "\Mozilla\Firefox\" & $Mozilla_Firefox_profile_folder & "\prefs.js"
; String to find
$StringToFind = '"browser.startup.homepage"'
; New home page address
$HomePageAddress = "" ; write the desired home page address (inside quotes), for example: http://www.google.com/
; Delete the current home page address
Global $Array
_FileReadToArray ($InputFile, $Array)
$Array = _DeleteHomePageAddress ($Array, $StringToFind)
_FileWriteFromArray ($InputFile, $Array, 1)
; Write a new home page address
$File = FileOpen($InputFile, 257) ; UTF8 encoding without BOM
FileWriteLine($File, 'user_pref("browser.startup.homepage", ' & '"' & $HomePageAddress & '"' & ');')
FileClose($File)
Func _DeleteHomePageAddress ($Array, $StringToFind)
Local $Item
For $Element In $Array
If StringInstr ($Element, $StringToFind) <> 0 Then
_ArrayDelete ($Array, $Item)
Else
$Item+=1
EndIf
Next
Return ($Array)
EndFunc
'도움말들.... > 오토잇' 카테고리의 다른 글
오토잇으로 설치 자동화 메크로.. (0) | 2012.09.05 |
---|---|
AutoIt 언어의 기초인 언어 레퍼런스 (0) | 2012.09.05 |
AutoIt과 Command Line 명령을 이용한 동기화(백업) 툴 (0) | 2012.09.05 |
WinRAR 4.11 한글 자동설치 스크립트 (0) | 2012.09.05 |
OS( x86) (x64) 구분 설치.. (0) | 2012.09.05 |