Welcome to the Liquidware Community Site.
Current and Future Clients/Partners are Welcome.

FireFox Default Profile Enforcement

If see this error. this is when Firefox sees your profile as old and creates a new profile.

to fix this issue you have two options:

RunOnce

firefox -CreateProfile default-release


Then create a shortcut with "C:\Program Files\Mozilla Firefox\firefox.exe" -p -no-remote default-release


OR you can run this powershell script which will look at your profile.INI and creates the Firefox shortcut with the proper profile.



## Firefox Default Fix ##


function Get-IniContent ($filePath)

{

  $ini = @{}

  switch -regex -file $FilePath

  {

    "^\[(.+)\]" # Section

    {

      $section = $matches[1]

      $ini[$section] = @{}

      $CommentCount = 0

    }

    "^(;.*)$" # Comment

    {

      $value = $matches[1]

      $CommentCount = $CommentCount + 1

      $name = "Comment" + $CommentCount

       $ini[$section][$name] = $value

    }

    "(.+?)\s*=(.*)" # Key

    {

      $name,$value = $matches[1..2]

      $ini[$section][$name] = $value

    }

  }

  return $ini

}



##########################


## Create icon Function ##


function set-shortcut( 

  [string]$SourceExe, 

  [string]$ArgumentsToSourceExe, 

  [string]$DestinationPath )

{

$WshShell = New-Object -comObject WScript.Shell

$Shortcut = $WshShell.CreateShortcut($DestinationPath)

$Shortcut.TargetPath = $SourceExe

$Shortcut.Arguments = $ArgumentsToSourceExe

$Shortcut.Save()

}


#########################


## Find Default Profile ##


$fireDef = Get-IniContent $env:appdata\Mozilla\Firefox\profiles.ini

$profiles = $fireDef | foreach-Object {$_.keys -match "Profile"}


foreach ($profile in $profiles){

if ($firedef.$profile.default -eq 1) {

 $Profnum = $profile

}

}


## Set Default Profile Name ##

$profilename = $fireDef.$Profnum.name


## Find User Desktop Location ##


$desktop = (Get-ItemProperty -Path Registry::"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders").desktop


## Delete Old Links ##

$FileName = "$desktop\Firefox.lnk"

if (Test-Path $FileName) {

 Remove-Item $FileName

}


$FileName = "$env:Public\Desktop\Firefox.lnk"

if (Test-Path $FileName) {

 Remove-Item $FileName

}


## Create ShortCut ##

set-shortcut "C:\Program Files\Mozilla Firefox\firefox.exe" -ArgumentsToSourceExe "-p -no-remote $profilename" -DestinationPath "$env:Public\Desktop\Firefox.lnk"

Comments

Sign In or Register to comment.