Yes there are changes that could be made to make this more specific (program files vs program files (x86)) or other customization... but the script is just a start.
Hopefully Dropbox will see it and they will address their client design for a all users deployment.
----- Powershell Script... Enjoy. -----
$dropboxexe = "Dropbox 2.10.52.exe"
$allusersprofile = (gci env:allusersprofile).value
$appdata = (gci env:appdata).value
$arguments= '/S /D=C:\Program Files\Dropbox'
$LASTEXITCODE = (Start-Process -FilePath $dropboxexe -ArgumentList $arguments -Passthru).ExitCode
$i=0
do
{
$i++
$ExplorerRunning = Get-Process explorer -EA 0
if ($ExplorerRunning -eq $null)
{
#if explorer stop restart it.
schtasks /Create /TN "DropBoxInstall" /TR explorer.exe /SC OnLogon /ru Users
schtasks /Run /TN "DropBoxInstall"
schtasks /Delete /TN "DropBoxInstall" /F
}
$dropboxexeRunning = Get-Process $($dropboxexe -replace ".exe") -EA 0
if ($dropboxexeRunning -eq $null)
{
#if install is complete then stop dropbox.exe from starting
kill -name dropbox -force
$i=999
}
Start-Sleep -m 500
} while ($i -lt 200)
#copy add remove programs entry
Remove-Item -path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Dropbox" -ea 0
copy-item -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Dropbox" -destination "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Dropbox"
#copy shortcuts
$PathFrom = "$($appdata)\Microsoft\Windows\Start Menu\Programs\Dropbox\*"
$PathTo = "$($allusersprofile)\Microsoft\Windows\Start Menu\Programs\Dropbox\"
Remove-item -path $PathTo -recurse
md $PathTo -ea 0
copy-item -path $PathFrom -destination $PathTo -recurse
To help others however I identified the following: For the 1st line: $dropboxexe = "Dropbox 2.10.52.exe" I had to add a fully qualified path (e.g c:\temp\Dropbox_3.2.9.exe, but that might be down to the way I invoked it.
copy-item -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Dropbox" -destination "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Dropbox" Requires a -Recurse switch to copy all the child items.
It also Creates the Dropbox key twice i.e. Uninstall\Dropbox\Dropbox so the desination needs to end \Uninstall" (so it takes the Dropbox key and places it in Uninstall not in Uninstall\Dropbox).
To avoid 2 entries for Dropbox appearing in Control Panel\Programs & Features we need:
Remove-Item -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Dropbox" -ea 0
I still had issues with the timing which I didn't get round to resolving, e.g. the script was trying to copy the shortcuts before they existed, so some further sleep required. - henryvii 9 years ago