Script to install/update files

i am using package maker to install templates into iweb. i have managed to set the installer up to install the files into the correct locations - but i still need to be able to do one thing.
in order for the templates to work they need to update a templates.plist file. the only way i can see package maker to do is this by giving it a script.
how can i create a script that will update the file by adding certain plist lines into alphabetical orderded lists (in the plist file)?
i cannot replace the existing file because they might all have different templates installed! it sort of needs to merge the files as in file-merger!
another sidenote - i basically have no knowledge of applescript, so dont be to hard on me
thanks,
max

Typically I would say using the shell command defaults is the way to go, but after looking at the file I don't think that will work. I don't have any templates to test this with, but this should work. It does make up a back up of your templates file to the desktop though just in case.
Currently it only works with one template, but by making the theme name variable a list and throwing the main logic block in a repeat through that list it would be easy to accomodate multiple files.
-- This works for a single file. Assuming though Multple files
-- it wouldn't be hard to make a list
(* ======== Change These For Your Theme ======== *)
set _themeName to "TESTING" -- Your Templates Name
set _themeVersion to "1.1" -- Some sort of version or compatability indicator??
(* === Nothing here down should need to be changed === *)
set _keys to {"About Me", "Blog", "Movie", "Photos", "Podcast", "Blank", "Welcome"}
set _deskPath to path to desktop as Unicode text
set _backupFolder to "iWeb Backup"
set _backupPath to _deskPath & _backupFolder
set _appPath to path to application "iWeb" as Unicode text
set _plistPath to _appPath & "Contents:Resources:English.lproj:Templates:TemplatesInfo.plist"
tell application "Finder"
if not (exists folder _backupPath) then
make new folder at _deskPath with properties {name:_backupFolder}
end if
tell application "Finder" to duplicate _plistPath to _backupPath
end tell
set _data to (read file _plistPath)
(* ====================== MAIN LOGIC BLOCK ======================*)
repeat with _keyValue in _keys
set _osString to ¬
" <key>" & _keyValue & "</key>
<dict>
<key>BLCategory</key>
<string>" & _keyValue & "</string>
<key>BLEntries</key>
<dict>"
set _insertString to ¬
" <key>" & _themeName & "</key>
<dict>
<key>displayName</key>
<string>" & _keyValue & "</string>
<key>fileName</key>
<string>" & _themeName & space & _keyValue & ".webtemplate</string>
</dict>"
set _theOffset to offset of _osString in _data
set _top to text 1 through (_theOffset + (count _osString)) of _data
set _bottom to text (_theOffset + (count _osString) + 1) through -1 of _data
set _data to _top & _insertString & (ASCII character 10) & _bottom
end repeat
set _osString to ¬
" <key>sortedThemes</key>
<array>"
set _insertString to ¬
" <dict>
<key>displayName</key>
<string>" & _themeName & "</string>
<key>keyName</key>
<string>" & _themeName & "</string>
<key>version</key>
<string>" & _themeVersion & " Themes</string>
</dict>"
set _theOffset to offset of _osString in _data
set _top to text 1 through (_theOffset + (count _osString)) of _data
set _bottom to text (_theOffset + (count _osString) + 1) through -1 of _data
set _data to _top & _insertString & (ASCII character 10) & _bottom
(* ==================== CLOSE MAIN LOGIC BLOCK ====================*)
try
close access file _plistPath
end try
set _fileRef to open for access _plistPath with write permission
set eof _fileRef to 0
write _data to _fileRef
close access _fileRef

Similar Messages

  • I cannot update or install updates on itunes. It says that the location for that file does not exist. I cant even uninstall itunes as the same error message comes up.

    I cannot update or install updates on itunes. It says that the location for that file does not exist. I cant even uninstall itunes as the same error message comes up.

    Hi vindog60,
    Thank you for using Apple Support Communities.
    To troubleshoot this issue where you get an installation error with iTunes on your Windows PC, please follow the steps in the article linked to below.
    Issues installing iTunes for Windows - Apple Support
    Cheers,
    Alex H.

  • Windows XP won't install drivers - "UPDATE" file missing

    I have installed Windows XP SP2 successfully ( it was a bumpy road ) and have reached the step where I'm supposed to use a Leopard disc to install the necessary drivers for using Windows with the MacBook hardware (video, speakers, etc). When I insert the Leopard disc a window appears saying that the setup.exe file on the disc is newer than something or other, so I click OKAY ( the Boot Camp instructions say to agree to any windows at this point ). The window goes away, and another one immediately opens saying " the necessary UPDATE file is missing". I click OKAY and the window closes. The End. No driver installation. I can use XP, but there is no sound. Windows Movie Maker won't even launch because it says the audio components are not available. This is probably because the drivers weren't installed. I imagine there will be many other problems.... Anyone have this solution???

    Here is a correction to my post. The window says: "This package requires a newer version of Windows Installer. Do you want to update the version of the Windows Installer on your system?" ( I click yes and the window goes away). The second window says: "The required resource 'Update' is missing". ( I click yes and the window goes away ).
    I think maybe XP is trying to download something from the internet and maybe it can't since I probably need the drivers to do that....?

  • Adobe Photoshop CS5 Windows Finnish update files failed to install/load

    Adobe Photoshop CS5 Windows Finnish update files failed to install/load.
    Loading updates fails at the end of the loading. Tried it yesterday and today same errors. Are the files corrupted at server or how to fix this ?
    Adobe Bridge CS5 4.0.5-update
    Adobe Extension Manager CS5 5.0-update
    Photoshop Camera Raw 6.7-update
    Photoshop CS5:n Photoshop 12.0.4-update

    update by downloading the files directly and then applying them:
    pre cc updates:  http://www.adobe.com/downloads/updates/

  • I download latest software update for itunes and iphone. they successfully download, but then a message comes up saying unable to install as file has been corrupted. what is the cause?

    I download latest updates for itunes and my iphone, when it comes to installing, it successfully downloads, but then i get a message for iphone software error=1403 file corrupted, and for itunes it downloads, then when i try to install it a message says unable to install software, file maybe corrupted!! 

    The iTunes update must be downloaded and installed before you try and use it to update the iPhone OS
    Download iTunes 10.2.2 from here: http://support.apple.com/kb/DL1103
    When it completes it will auto mount the disc image and show you the package installer, don't try and do anything with the file until it gets to this stage.
    Once that's installed reboot the Mac, run iTunes, connect your iPhone and let it sync, then hit the update button and let it complete that step by itself (which will require a restart of the iPhone)

  • HT4007 I reinstalled Aperture 3. Do I have to install every single update files or only the latest one?

    Hi All.
    I just reinstalled Aperture 3.
    I'm just wondering do I have to install every update files by in order? or do I just need to install the latest one?
    Please let me know.
    Thank you.

    Just run Software Update (or from the App Store) and let Apple do the rest.  It should bring you completely up-to-date.

  • Script to install and enable file and printer sharing windows 7

    Hello
    I posted this question on the Microsoft Partner Windows 7 forum and the support person told me that I should post it here.
    I have a Customer that was running Novell.  We will migrate them to Active Directory.
    The question I have is.  they did remove the file and printer sharing service on their Windows 7 workstations.
    Is is possible to have a command line or a script to install and enable the file and printer sharing for Microsoft Network?
    We need this enable in order to install the SCCM client remotely
    Greetings
    Gaetan Labrecque

    How are you going to connect to the workstations?
    File and print sharing are not needed for Group Policy to work.  GP can be used to re-enable file and Print Sharing.
    You will also  need to start by joining the machines to the domain.  That will be very difficult unless all have PowerShell and are configured for WinRM.
    This can be somewhat accomplished by using VBScript remotely but will require a very sophisticated admin to set up and debug in your environment.  I recommend hiring a consultant who has experience in conversions or is a master VBScripter in a domain.
    There is no easy answer.  It is not about File Sharing.
    Here is how to add roles and features with PowerShell:
    http://technet.microsoft.com/en-us/library/hh831809.aspx
    ¯\_(ツ)_/¯

  • Can't install Updates (run preinstall script)

    Hello, recently I can't install updates from apple. I get the following messages:
    Quicktime 7.62:
    The following install step failed: run prefight script for QuickTime 7. Contact the software manufacturer for assistance.
    Leopard 10.5.7:
    The following install step failed: run preinstall script for MacOSXUpd10.5.7. Contact the software manufacturer for assistance.
    iWork '09 Update 2 (9.0.2):
    The following install step failed: run prefight script for iWork '09 Update. Contact the software manufacturer for assistance.
    The same for iTunes 8.2 and iPhone SDK 3.0 beta 5.
    Can someone help me?
    Thank you,
    pat from Germany

    Hello...
    I am having the exact same problem this person was having, except that I wasn't able to repair permissions. When I attempt to do this, I get this message:
    The underlying task reported failure on exit.
    Does this mean that I have to do an Archive and Install? In which case, would you mind walking me through that process? <:)
    I really have no idea why this is occurring, as well..if you could explain that to me, I'd be very grateful.

  • I continue to receive "failed to mount" when trying to install .dmg files or updates.  Has anyone found an answer to this problem?  I am operating on Mac OS X 10.4.11

    I continue to receive "failed to mount" when trying to install .dmg files or updates.  Has anyone found an answer to this problem?  I am operating on Mac OS X 10.4.11

    10.4.11 was only available as a PowerPC updater application (both as a Combo and as a Delta) to Macs with 10.4 or later that were PowerPC. If you don't have 10.4 installed on your Mac, see this tip:
    https://discussions.apple.com/docs/DOC-2541

  • Install Updates Failed:Preflight Script???

    Nobody answered the only archived question similar to mine. I got the following message when trying to install updates: _+None of the checked updates could be installed: run preflight script for...+_.
    Has anyone else had this problem and a solution?
    Thanks.

    Next thing to try is...
    Use Disk Utility to verify/Repair the HD, then Repair Permissions then reboot.
    Use the Archive and Install feature...
    http://docs.info.apple.com/article.html?artnum=107120
    Repair Permissions afterwards, reboot.
    After that would be a complete Zeroing of the HD and a fresh Install.

  • Write-Progress in PowerShell script for installing Missing Updates

    Hi, I had a previous question here
    https://social.technet.microsoft.com/Forums/windowsserver/en-US/88931488-3b2c-4c08-9ad3-6651ba9bbcef/action?threadDisplayName=progress-indicator-for-installing-missing-sccm-2012-r2-updates
    But that method is not working as expected.  The progress bar displays then continues to increment past 100 throwing an error each time.
    I'm thinking I could use a foreach loop for the missing updates but I'm just lost when it comes to Powershell syntax.
    For example:
    # Get the number of missing updates
    [System.Management.ManagementObject[]] $CMMissingUpdates = @(GWMI -ComputerName $server -query "SELECT * FROM CCM_SoftwareUpdate WHERE ComplianceState = '0'" -namespace "ROOT\ccm\ClientSDK") #End Get update count.
    $result.UpdateCountBefore = "The number of missing updates is $($CMMissingUpdates.count)"
    #Install missing updates.
    #Begin example code, not tested.
    Foreach ($update in $CMMissingUpdates)
    $i++
    If ($CMMissingUpdates.count) {
    $CMInstallMissingUpdates = (GWMI -ComputerName $server -Namespace "root\ccm\clientsdk" -Class "CCM_SoftwareUpdatesManager" -List).InstallUpdates($CMMissingUpdates)
    Do {
    Start-Sleep -Seconds 15
    [array]$CMInstallPendingUpdates = @(GWMI -ComputerName $server -query "SELECT * FROM CCM_SoftwareUpdate WHERE EvaluationState = 6 or EvaluationState = 7" -namespace "ROOT\ccm\ClientSDK")
    #end my example code.
    #The code below is working to install updates but Write-Progress isn't.
    If ($CMMissingUpdates.count) {
    #$result.UpdateCountBefore = "The number of missing updates is $($CMMissingUpdates.count)"
    $CMInstallMissingUpdates = (GWMI -ComputerName $server -Namespace "root\ccm\clientsdk" -Class "CCM_SoftwareUpdatesManager" -List).InstallUpdates($CMMissingUpdates)
    #Set the missing updates to variable for progress indicator.
    $updates = $CMMissingUpdates.Count
    $Increment = 100 / $updates
    $Percent = 0
    Do {
    Start-Sleep -Seconds 15
    [array]$CMInstallPendingUpdates = @(GWMI -ComputerName $server -query "SELECT * FROM CCM_SoftwareUpdate WHERE EvaluationState = 6 or EvaluationState = 7" -namespace "ROOT\ccm\ClientSDK")
    #Not 100% sure $result.UpdateCountBefore is needed below.
    $result.UpdateCountBefore = "The number of pending updates for installation is: $($CMInstallPendingUpdates.count)"
    Write-Progress -Activity "Updates are installing..." -PercentComplete $Percent -Status "Working..."
    $Percent = $Percent + $Increment
    } While (($CMInstallPendingUpdates.count -ne 0) -and ((New-TimeSpan -Start $StartTime -End $(Get-Date)) -lt "00:45:00"))
    Write-Progress -Activity "Updates Installed" -Status "Done" -Completed
    } ELSE {
    $result.UpdateCountAfter = "There are no missing updates."}
    $result

    The increment should be 100  / (max number of items)
    That will not exceed 100 through (max number of items ) iterations in a loop
    Mathematically that can be written as 
    100 / (Max Number of items) * (max number of items ) iterations in a loop
    = 100 * ( (Max Number of Item) / (Number Iterations in a loop) )
    = 100 * 1 = 100
    The (max number of items) and (Number of Iterations in a loop ) need to be based on the same number.
    In the script, it is not based on the same number.
    The maximum number of items is $CMMissingUpdates.Count
    The number of iterations in the loop  is based on the condition 
    ($CMInstallPendingUpdates.count -ne 0)
    Which causes the iterations of the loop to exceed $CMMissingUpdates.Count
    Assuming the $CMInstallPendingUpdates.count is going down (is decremented) through the loop, then
    $Increment = 100 /
    $CMInstallPendingUpdates.count

  • Smart file examiner wont install updates for office on my macbook air. i click step two for show info then nothing happens

    I just got my my macbook air and I am still learning how to use it. I just put Office 2011 on it and there was an update for it after i installed it. I did the update and it downloaded it but then instead of installing Smart File Examiner opens and step 1 sleect file and this is were is went /Users/user/Library/Caches/TemporaryItems/3114AutoUpdate Installer.mpkg. Then it says information gathered successfully. step 2 click show information button. so I do and and the info on it opens in a new page, but it does not do anything else. So how do i finsh installing the update?

    Downloading as we speak, and the first explanation that comes to mind is that both files have a .rar extension, and that since OS X doesn't support this archive format, you need to install a third-party utility to open them.
    One files tool to open .rar files is The Unarchiver (here), and another is Stuffit Expander (there). 7zip also proposes a Mac version (here). All three will decompress a .rar file, and let you access the .dmg file(s) inside.
    Also, depending on the browser you're using, and provided you might be inclined to open trusted files directly (I use Opera, and seldom save safe download; I click on "Open" in the download dialogue), your files could very well open... in the browser cache folder, out of sight. But if you use Safari, Chrome or Firefox, and you don't have any utility installed to handle .rar files, that's doubtful. I'm going to open your files now, and check if I can install them.
    Stay tuned!
    Edit: decompressing the first file using The Unarchiver shows that the archive is "incomplete". Which leads me to think that you might have to concatenate the two files to make one "complete" .dmg file.
    If so, once they are decompressed, open a Terminal (in Applications/Utility), then type "cat", and drag both files in the window, one after the other (preferably in the right order...), type a space, then give the final file any name you want, followed by the .dmg file extension:
    (e.g.:) "cat /Users/Your_Name/Desktop/File1.dmg /Users/Your_Name/File2.dmg /Users/Your_Name/Desktop/FinalFile.dmg"

  • Cant unninstall lightroom 5.4 needed for install update 5.5, i have delete all file and registry but install fails

    Cant unninstall lightroom 5.4 needed for install update 5.5, i have delete all file and registry but install fails again and again, now i i cant use lightrrom .. grins.
    I use SSD disk and i cant have lot of uninstal file (have to clean disk often)
    Thanks for help

    Hello Jeff,
    Many thanks for your answer, i use windows 8.1! I have found the problems: For install the news version the install need the old installer (but i delete all installer, cause they use a lot place on hard drive  (SSD)).
    I have desinstall the whole Adobe and réinstalled it, i have save the whole installer on a external disk. So when the installer asked the old installer i indicate to programm my external disk ans all works good now.
    Many thanks for you help, i have just do not to delete old file (sad to have to save old installler just for install the new).
    Wallie
    (sorry my english)

  • Script to install Windows Updates, but do not restart

    I found this script that prompts for Y or N to install updates and again to reboot.
    I would like it to go ahead install updates without asking, but NOT reboot.  We want to reboot the machines remotely and manually by putting their host names in a shutdown -i command.
    So basically I want it to automatically assume "Y" for installing and "N" for rebooting.
    See the script text below.  How does it need to be changed to do this?
    # Script: WSUS.ps1
    # Author: Gregory Strike
    # Website: www.GregoryStrike.com
    # Date: 02-19-2010
    # Information: This script was adapated from the WUA_SearchDownloadInstall.vbs VBScript from Microsoft. It uses the
    # Microsoft.Update.Session COM object to query a WSUS server, find applicable updates, and install them.
    # WSUS.ps1 is a little less verbose about what it is doing when compared to the orginal VBScript. The
    # lines exist in the code below to show the same information as the original but are just commented out.
    # WSUS.ps1 can automatically install applicable updates by passing a Y to the script. The default
    # behavior is to ask whether or not to install the new updates.
    # Syntax: .\WSUS.ps1 [Install] [Reboot]
    # Where [Install] is optional and can be "Y", "Yes", "No" or "N"
    # Whether or not to install the updates automatically. If Null, the user will be prompted.
    # Where [Reboot] is optional and can be "Y", "Yes", "No" or "N", This
    # If updates require a reboot, whether or not to reboot automatically. If Null, the user will
    # be prompted.
    $UpdateSession = New-Object -Com Microsoft.Update.Session
    $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
    Write-Host("Searching for applicable updates...") -Fore Green
    $SearchResult = $UpdateSearcher.Search("IsInstalled=0 and Type='Software'")
    Write-Host("")
    Write-Host("List of applicable items on the machine:") -Fore Green
    For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
    $Update = $SearchResult.Updates.Item($X)
    Write-Host( ($X + 1).ToString() + "&gt; " + $Update.Title)
    If ($SearchResult.Updates.Count -eq 0) {
    Write-Host("There are no applicable updates.")
    Exit
    #Write-Host("")
    #Write-Host("Creating collection of updates to download:") -Fore Green
    $UpdatesToDownload = New-Object -Com Microsoft.Update.UpdateColl
    For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
    $Update = $SearchResult.Updates.Item($X)
    #Write-Host( ($X + 1).ToString() + "&gt; Adding: " + $Update.Title)
    $Null = $UpdatesToDownload.Add($Update)
    Write-Host("")
    Write-Host("Downloading Updates...") -Fore Green
    $Downloader = $UpdateSession.CreateUpdateDownloader()
    $Downloader.Updates = $UpdatesToDownload
    $Null = $Downloader.Download()
    #Write-Host("")
    #Write-Host("List of Downloaded Updates...") -Fore Green
    $UpdatesToInstall = New-Object -Com Microsoft.Update.UpdateColl
    For ($X = 0; $X -lt $SearchResult.Updates.Count; $X++){
    $Update = $SearchResult.Updates.Item($X)
    If ($Update.IsDownloaded) {
    #Write-Host( ($X + 1).ToString() + "&gt; " + $Update.Title)
    $Null = $UpdatesToInstall.Add($Update)
    $Install = [System.String]$Args[0]
    $Reboot = [System.String]$Args[1]
    If (!$Install){
    $Install = Read-Host("Would you like to install these updates now? (Y/N)")
    If ($Install.ToUpper() -eq "Y" -or $Install.ToUpper() -eq "YES"){
    Write-Host("")
    Write-Host("Installing Updates...") -Fore Green
    $Installer = $UpdateSession.CreateUpdateInstaller()
    $Installer.Updates = $UpdatesToInstall
    $InstallationResult = $Installer.Install()
    Write-Host("")
    Write-Host("List of Updates Installed with Results:") -Fore Green
    For ($X = 0; $X -lt $UpdatesToInstall.Count; $X++){
    Write-Host($UpdatesToInstall.Item($X).Title + ": " + $InstallationResult.GetUpdateResult($X).ResultCode)
    Write-Host("")
    Write-Host("Installation Result: " + $InstallationResult.ResultCode)
    Write-Host(" Reboot Required: " + $InstallationResult.RebootRequired)
    If ($InstallationResult.RebootRequire -eq $True){
    If (!$Reboot){
    $Reboot = Read-Host("Would you like to install these updates now? (Y/N)")
    If ($Reboot.ToUpper() -eq "Y" -or $Reboot.ToUpper() -eq "YES"){
    Write-Host("")
    Write-Host("Rebooting...") -Fore Green
    (Get-WMIObject -Class Win32_OperatingSystem).Reboot()

    You could try  reading the instructions posted with the script.  It might be helpful to you.
    ¯\_(ツ)_/¯

  • 10.5.4 Update: The Installer could not install some files in "/"

    I am unable to install 10.5.4 on my Intel iMac. I have rebooted multiple times, disconnected all external drives including my printer and tried the installer with no success. I have not found anything pointing to why on the forums. Any assistance would be helpful.
    Model Name: iMac
    Model Identifier: iMac4,1
    Processor Name: Intel Core Duo
    Processor Speed: 2 GHz
    Number Of Processors: 1
    Total Number Of Cores: 2
    L2 Cache: 2 MB
    Memory: 2 GB
    Bus Speed: 667 MHz
    Boot ROM Version: IM41.0055.B08
    SMC Version: 1.1f5
    Thanks,

    I am having the same issue, and a permissions repair did nothing for me.
    I have attempted an install from software update, downloaded both the 10.5.3/4 combo update, and the 10.5.4 update and manually tried to install, each time with the same error: The Installer could not install some files in "/"

Maybe you are looking for