Statistics: Posted by muhammadFarooq2k20 — Fri May 03, 2024 1:14 pm — Replies 15115 — Views 3726609
Statistics: Posted by JohnnyRy — Fri May 03, 2024 9:24 am — Replies 5 — Views 1049
Code: Select all
################################################ Create of task schedule if there not exists with this script$TaskName = "Control versions for MetaTrader 4"# Check if the schedule task existsif (Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue) { Write-Host "The schedule task '$TaskName' already exists, to this script will not take any action"} else { Write-Host "The schedule task '$TaskName' not exists. Then wait while this process is finished" ############################################### # Control versions of indicators and experts based on property version Write-Host "Control versions of indicators and experts based on property version" $host.ui.RawUI.WindowTitle = "Control versions of indicators and experts based on property version" Write-Host "Resume what is does this specific task" Write-Host " Step 1: Control versions of indicators and experts based on property version" Write-Host " Step 1.1: Control versions of indicators and experts based on property version :: Create task schedule" Write-Host " Step 1.2: Control versions of indicators and experts based on property version :: Create necessary script" Write-Host " Step 1.3: Control versions of indicators and experts based on property version :: Add necessary and missed information" Write-Host " Step 1.3.1: Control versions of indicators and experts based on property version :: Declare source file" Write-Host " Step 1.3.2: Control versions of indicators and experts based on property version :: Line necessary to add missed information" Write-Host " Step 1.3.3: Control versions of indicators and experts based on property version :: Text to be add" Write-Host " Step 1.3.4: Control versions of indicators and experts based on property version :: Read entire file" Write-Host " Step 1.3.5: Control versions of indicators and experts based on property version :: Add the information need" Write-Host " Step 1.3.6: Control versions of indicators and experts based on property version :: Write the updated lines back to the file" Write-Host " Step 1.4: Control versions of indicators and experts based on property version :: Stop this script" ############################################### # Control versions of indicators and experts based on property version # Step 1: Control versions of indicators and experts based on property version # Step 1.1: Control versions of indicators and experts based on property version :: Create task schedule $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument 'C:\SCRIPTS\MT-ControlVersions.ps1}' $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) -RepetitionInterval (New-TimeSpan -Minutes 1) $principal = New-ScheduledTaskPrincipal -UserId "$env:USERDOMAIN\$env:USERNAME" -LogonType "S4U" -RunLevel Highest Register-ScheduledTask -TaskName "TRADING\Control versions for MetaTrader 4" -Action $action -Trigger $trigger -Principal $principal -Force $TaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries Set-ScheduledTask -TaskName "TRADING\Control versions for MetaTrader 4" -Settings $TaskSettings # Step 1.2: Control versions of indicators and experts based on property version :: Create necessary script Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '# Source of your repository' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '$RootFolder = "C:\SourceFolder"' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '# Destiny folder for the files classified with version' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '$Destination = "C:\DestinationFolder"' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '# Obtém todos os arquivos no diretório de origem' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '$Files = Get-ChildItem -Path $RootFolder -File -Recurse' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '# File interaction' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" 'foreach ($File in $Files) {' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '# Read the content of every file' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '$Content = Get-Content -Path $File.FullName' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '# Find for the line contains the information property version' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '$VersionLine = $Content | Where-Object { $_ -match "property version" }' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '# If is valid so' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" 'if ($VersionLine) {' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '# Extract a version for that' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" '$Version = $VersionLine -replace "property version", "" -replace ''([A-Z]| |#|")', '' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' # Create the destination folder, with base on version and name of file' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' $DestinationPath = Join-Path -Path $Destination -ChildPath "$Version\$($File.BaseName)"' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' # And if the folder of destionation does not exist, so create that one' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' if (-not (Test-Path -Path $DestinationPath)) {' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' New-Item -Path $DestinationPath -ItemType Directory' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' }' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' # Copy the file for destination' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" 'Copy-Item -Path $File.FullName -Destination $DestinationPath -Force' Add-Content "C:\SCRIPTS\MT-ControlVersions.ps1" ' ' # Step 1.3: Control versions of indicators and experts based on property version :: Add necessary and missed information # Step 1.3.1: Control versions of indicators and experts based on property version :: Declare source file $FileToCorrect = "C:\SCRIPTS\MT-ControlVersions.ps1" # Step 1.3.2: Control versions of indicators and experts based on property version :: Line necessary to add missed information $Line = 23 # Step 1.3.3: Control versions of indicators and experts based on property version :: Text to be add $txtADD = "', ''" # Step 1.3.4: Control versions of indicators and experts based on property version :: Read entire file $Lines = Get-Content -Path $FileToCorrect # Step 1.3.5: Control versions of indicators and experts based on property version :: Add the information need $Lines[$Line - 1] += $txtADD # Step 1.3.6: Control versions of indicators and experts based on property version :: Write the updated lines back to the file $Lines | Set-Content -Path $FileToCorrect # Step 1.3: Control versions of indicators and experts based on property version :: Stop this script $sh = New-Object -ComObject "Wscript.Shell" $sh.Popup("The creation of this task schedule task is conclude", 2, "www.forex-station.com", 0 + 64)}
Statistics: Posted by Curioso — Fri May 03, 2024 8:31 am — Replies 2 — Views 308
Statistics: Posted by JohnnyRy — Fri May 03, 2024 8:23 am — Replies 156 — Views 5965
Statistics: Posted by JohnnyRy — Fri May 03, 2024 7:58 am — Replies 1 — Views 156
Statistics: Posted by BillyIdol — Fri May 03, 2024 6:01 am — Replies 4052 — Views 1062916
Statistics: Posted by kvak — Fri May 03, 2024 5:35 am — Replies 767 — Views 322919
Statistics: Posted by kvak — Fri May 03, 2024 5:31 am — Replies 74 — Views 35950
Statistics: Posted by TEAMTRADER — Fri May 03, 2024 4:31 am — Replies 3817 — Views 944447
Statistics: Posted by REDntense — Fri May 03, 2024 2:46 am — Replies 97 — Views 10238
Statistics: Posted by mrtools — Fri May 03, 2024 2:09 am — Replies 564 — Views 160242
Statistics: Posted by ionone — Fri May 03, 2024 1:54 am — Replies 0 — Views 91
Statistics: Posted by boytoy — Fri May 03, 2024 1:01 am — Replies 20413 — Views 4987331
Statistics: Posted by guner — Fri May 03, 2024 1:00 am — Replies 1021 — Views 80610
Statistics: Posted by charli — Fri May 03, 2024 12:29 am — Replies 791 — Views 38295