Statistics: Posted by ionone — Fri May 03, 2024 6:09 pm — Replies 2 — Views 180
Statistics: Posted by ionone — Fri May 03, 2024 6:02 pm — Replies 1 — Views 144
Statistics: Posted by xard777 — Fri May 03, 2024 5:33 pm — Replies 15116 — Views 3727655
Statistics: Posted by Ogee — Fri May 03, 2024 5:08 pm — Replies 1 — Views 129
Statistics: Posted by ixion700 — Fri May 03, 2024 4:55 pm — Replies 3818 — Views 948332
Statistics: Posted by macd & rsi — Fri May 03, 2024 4:41 pm — Replies 20 — Views 1591
Statistics: Posted by Ogee — Fri May 03, 2024 4:36 pm — Replies 2804 — Views 164667
Statistics: Posted by Ogee — Fri May 03, 2024 4:06 pm — Replies 36 — Views 1944
Statistics: Posted by Ogee — Fri May 03, 2024 3:59 pm — Replies 667 — Views 58537
Statistics: Posted by Mrtrader — Fri May 03, 2024 3:54 pm — Replies 2807 — Views 1217458
Statistics: Posted by guner — Fri May 03, 2024 3:32 pm — Replies 1024 — Views 80745
Statistics: Posted by JohnnyRy — Fri May 03, 2024 9:24 am — Replies 5 — Views 1072
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 325
Statistics: Posted by JohnnyRy — Fri May 03, 2024 8:23 am — Replies 156 — Views 5975
Statistics: Posted by BillyIdol — Fri May 03, 2024 6:01 am — Replies 4052 — Views 1063369