Statistics: Posted by JohnnyRy β Fri May 03, 2024 9:24 am β Replies 5 β Views 1024
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 275
Statistics: Posted by JohnnyRy β Fri May 03, 2024 8:23 am β Replies 156 β Views 5949
Statistics: Posted by JohnnyRy β Fri May 03, 2024 7:58 am β Replies 1 β Views 135
possible long
Statistics: Posted by Redman β Fri May 03, 2024 5:58 am β Replies 15114 β Views 3725949
Statistics: Posted by kvak β Fri May 03, 2024 5:35 am β Replies 767 β Views 322812
Statistics: Posted by kvak β Fri May 03, 2024 5:31 am β Replies 74 β Views 35913
Statistics: Posted by TEAMTRADER β Fri May 03, 2024 4:31 am β Replies 3817 β Views 941660
Statistics: Posted by REDntense β Fri May 03, 2024 2:46 am β Replies 97 β Views 10218
Statistics: Posted by mrtools β Fri May 03, 2024 2:09 am β Replies 564 β Views 160169
Statistics: Posted by ionone β Fri May 03, 2024 1:54 am β Replies 0 β Views 80
Statistics: Posted by boytoy β Fri May 03, 2024 1:01 am β Replies 20413 β Views 4986389
Statistics: Posted by guner β Fri May 03, 2024 1:00 am β Replies 1021 β Views 80564
Statistics: Posted by charli β Fri May 03, 2024 12:29 am β Replies 791 β Views 38245