We do the same here at SMUD too! Except our guys update their maps in the field through a Verizon VPN Cloud, 4G LTE!!
We added a "Map Update" in the Menu form that calls a bat script which calls a powershell script to download the zipped map file, enhacement files, or fixes.
Menu.htm
function m_updateMap() //for Menu.htm
{
WshShell = new ActiveXObject("WScript.Shell");
try{
WshShell.Run("file:///C:/Win32app/ingr/IMobileTC/MobileInservice/Configurations/Custom/Scripts/Get-MobileTCMap.bat");
}
catch(err){
displayBriefError("Map Update File Not Found!, Plese Contact OMS Administrator!");
}
}
Get-MobileTCMap.bat
@echo off
Start Powershell.exe -NoExit -file \\web01server\MapzipfileShare\Get-MobileTCMap.ps1
Get-MobileTCMap.ps1
tried to upload the ps1, apparently HxGN doesn't like the attachment. NOTE!!! Execution Policies for running powershell scripts by default are set to restricted, you may have to go to the client machine launch both powershell and powershell (x86) and unrestricted the execution policy. here's the command: Set-ExecutionPolicy Unrestricted -Force, if you sign the .ps1 this command isn't required we didnt' sign it because we only have 150 users.
<#
.Description
Get Mobile TC mapfile
Last changed 20160519 - Steven On
#>
################# Logging ###################################################
#logging Vars
$logfile="c:\temp\MobileTCClientMapUpdate.txt"
$logCheck=Test-Path -Path $logFile
#log check if not there create one!
if(!$logCheck){
New-Item -Path "c:\temp\" -Name MobileTCClientMapUpdate.txt -ItemType file -Force -EA silentlycontinue | Out-Null
}
$logFileCDate=Get-ChildItem $logFile | Select CreationTime
$logFileCDate=$logFileCDate.CreationTime
$logFile2W=$logFileCDate.AddDays(30)
#if log is older than 30 days delete and create a new one!
if($logFileCDate -gt $logFile2w){
Remove-Item -Path $logFile -Force | Out-Null
New-Item -Path c:\temp\ -Name MobileTCClientMapUpdate.txt -ItemType file -Force -EA silentlycontinue | Out-Null
}
#logging function
function log($string)
{
$todaysDate = get-date
$todayDate = $todaysDate.ToShortDateString() +" "+ $todaysDate.ToShortTimeString()
$string = $todayDate + ": " + $string
$string | Out-File -FilePath $logfile -append
}
################# MAIN PROCESS ##############################################
$istag = Get-WMIObject -Class win32_systembios | Select __SERVER
$istag = $istag.__SERVER
write-host " _____ __ __ _ _ _____ _ _ _ __ "
write-host " / ____| \/ | | | | __ \ (_) _| || |/_ |"
write-host "| (___ | \ / | | | | | | | _ ___ |_ __ _| |"
write-host " \___ \| |\/| | | | | | | | | / __| _| || |_| |"
write-host " ____) | | | | |__| | |__| | | \__ \ |_ __ _| |"
write-host "|_____/|_| |_|\____/|_____/ |_|___/ |_||_| |_|"
Write-Host ""
$smudMapDate=gci C:\win32app\ingr\IMobileTC\MobileInservice\Configurations\Custom\maps\smud_mobile.map -EA silentlycontinue | Select LastWriteTime
$curDate = get-date
$curShortDate = $curDate.toShortDateString()
$curShortDateTime = $curShortDate + " 12:30:00 AM"
$formatSmudMapDate= $smudMapDate.LastWritetime
if($smudMapdate -eq $null){
log($istag)
log("No Map File Found")
log("")
Write-Host "No Map File Found" -ForegroundColor Red
Write-Host ""
}
else{
log($istag)
log("Map Date`: $formatSmudmapdate")
log("")
Write-Host "Map Date`: $formatSmudmapdate"
Write-Host ""
}
if($smudMapDate.LastWritetime -gt $curShortDateTime){
log("Your Map is up to date")
log("")
Write-Host "Your Map is up to date" -ForegroundColor Green
Write-Host ""
$exitMe=Read-Host "Press Enter to Exit!"
if($exitMe.length -ge 0){stop-process -name powershell -force -EA silentlycontinue}
}
else{
log($istag)
log("Map Date`: $formatSmudmapdate")
log(".....Copying smud_map.zip")
Write-Host ".....Copying smud_map.zip"
New-Item -Path c:\temp -Name mobileTCFiles -ItemType directory -Force | Out-Null
#file location Vars
$zipMap="c:\temp\mobileTCfiles\smud_map.zip"
$fileLoc="c:\temp\mobileTCfiles"
$mobileTCMap="C:\win32app\ingr\IMobileTC\MobileInservice\Configurations\Custom\Maps"
$mobileTCMapZip= $mobileTCMap + "\smud_mobile.zip"
$mobileTCMapZipLoc="C:\win32app\ingr\IMobileTC\MobileInservice\Configurations\Custom\Maps\smud_map.zip"
$goldenLoc="\\server15\sup_sdit\oms_mdd\Change_Control\92\Development\MobileTC_Post_Go_live\win32app"
$enhacementList="C:\win32app"
try{
Copy-Item -Path "\\swppoms92web01\OMS_MAP\smud_map.zip" -Destination $fileLoc -ErrorAction stop | Out-Null
}
catch{
Remove-Item -Path $fileLoc -Force -Recurse
Write-Host "Copy Zip Map Action Error: No access to \\swppoms92web01\OMS_MAP `n Contact The MobileTC Administrator" -ForegroundColor Red
log("Copy Zip Map Action Error: No access to \\swppoms92web01\OMS_MAP `n Contact The MobileTC Administrator")
log($error)
}
$error.clear()
Write-Host ".....Unzipping smud_map.zip"
log(".....Unzipping smud_map.zip")
#Unzip Copy Vars
$helper = New-Object -ComObject Shell.Application
$files = $helper.NameSpace($zipMap).Items()
$helper.NameSpace($fileLoc).CopyHere($files)
Start-Sleep -Seconds 2
Write-Host ".....Closing MobileTC"
log(".....Closing MobileTC")
Stop-Process -Name IngrViewer -Force -EA silentlycontinue | Out-Null
Remove-Item -Path c:\win32app\ingr\IMobileTC\MobileInservice\Configurations\Custom\Maps\* -force -erroraction silentlycontinue
Write-Host ".....Updating MapFile"
log(".....Updating MapFile")
Copy-Item -Path "$fileLoc\*" -Destination $mobileTCMap -Force -ErrorAction silentlycontinue
$error.clear()
Write-Host "......Updating Enhacement Files" -ForegroundColor Yellow
log(".....Updating Enhacement Files")
Copy-Item -Path "$goldenLoc\*" -Destination $enhacementList -Recurse -Force -ErrorAction silentlycontinue
$error.clear()
Remove-Item -Path $fileLoc -Force -Recurse -ErrorAction silentlycontinue
Remove-Item -Path $mobileTCMapZipLoc -Force -ErrorAction silentlycontinue
Write-Host ""
Write-Host ""
Write-Host "Mapfiles Updated!" -ForegroundColor Green
log("Mapfiles Updated!")
$exitMe=Read-Host "Press Enter to restart MobileTC"
$prc="C:\Users\Public\Desktop\MobileTc.lnk"
Start-Process -FilePath $prc -PassThru
if($exitMe.length -ge 0){
stop-process -name powershell -force -EA silentlycontinue
}
}