同花順節假日文件更新腳本

相信你們在作同花順系統運維時候碰到很多重複勞動,如節假日文件,手動更新很是麻煩,可作成以下powershell腳本downholiday.ps1實現自動更新:
#定義參數,各服務器根據須要修改此處。
$SavePath='c:\ths\'
$SaveIni="20181231;20190101;20190204-20190210;20190405-20190407;20190501-20190503;20190607-20190609;20190913-20190915;20191001-20191007;"
$NetFile='https://download.cfzq.com/sj/holiday.ini'shell

#kill全部發送
taskkill /im hexinvss.exe /f
taskkill /im shex.exe /f
taskkill /im shhk.exe /f
taskkill /im shszcalc.exe /f
taskkill /im options.exe /f
taskkill /im stb.exe /f
Start-Sleep -s 3api

#同花順dos界面發送節假日更新腳本
$SaveFile1=$SavePath+'hexinvss_binary\conf\holiday.ini'
$SaveFile2=$SavePath+'hexinvss_szhq\conf\holiday.ini'
$SaveFile3=$SavePath+'hexinvss_szwt\conf\holiday.ini'
$SaveFile4=$SavePath+'hexinvss_skhq\conf\holiday.ini'
$SaveFile5=$SavePath+'hexinvss_skwt\conf\holiday.ini'
$SaveFile6=$SavePath+'shex_hq\conf\holiday.ini'
$SaveFile7=$SavePath+'shex_wt\conf\holiday.ini'
$SaveFile8=$SavePath+'hgt\shhk\conf\holiday.ini'
$SaveFile9=$SavePath+'shszcalc\conf\holiday.ini'
$SaveFile10=$SavePath+'Options\Options.ini'
$SaveFile11=$SavePath+'stb_hq\conf\holiday.ini'
$SaveFile12=$SavePath+'stb_wt\conf\holiday.ini'服務器

Get-ExecutionPolicy
$ConfirmPreference = 'None'
Set-ExecutionPolicy UnRestricted運維

$client = new-object System.Net.WebClient
$client.DownloadFile($NetFile,$SaveFile1)
$client.DownloadFile($NetFile,$SaveFile2)
$client.DownloadFile($NetFile,$SaveFile3)
$client.DownloadFile($NetFile,$SaveFile4)
$client.DownloadFile($NetFile,$SaveFile5)
$client.DownloadFile($NetFile,$SaveFile6)
$client.DownloadFile($NetFile,$SaveFile7)
$client.DownloadFile($NetFile,$SaveFile8)
$client.DownloadFile($NetFile,$SaveFile9)
$client.DownloadFile($NetFile,$SaveFile11)
$client.DownloadFile($NetFile,$SaveFile12) ide

#上海個股期權更新,要先關閉程序
#加載winapi
$ini = Add-Type -memberDefinition @"
[DllImport("Kernel32")]
public static extern long WritePrivateProfileString (
string section ,
string key ,
string val ,
string filePath );
[DllImport("Kernel32")]
public static extern int GetPrivateProfileString (
string section ,
string key ,
string def ,
StringBuilder retVal ,
int size ,
string filePath );
"@ -passthru -name MyPrivateProfileString -UsingNamespace System.Textui

#定義配置
$section="Options"
$filePath=$SaveFile10
$key="MarketCloseHoliday"
$val=$SaveIni
$retVal=New-Object System.Text.StringBuilder(200)spa

#生成或修改配置文件
$null=$ini::WritePrivateProfileString($section,$key,$val,$filePath)get

#查看配置文件
$null=$ini::GetPrivateProfileString($section,$key,"",$retVal,200,$filePath)
Write-Host $key "=" $retVal.tostring()string

#啓動全部發送
$SavePath1=$SavePath+'hexinvss_binary\bin\'
$SavePath2=$SavePath+'hexinvss_szhq\bin\'
$SavePath3=$SavePath+'hexinvss_szwt\bin\'
$SavePath4=$SavePath+'hexinvss_skhq\bin\'
$SavePath5=$SavePath+'hexinvss_skwt\bin\'
$SavePath6=$SavePath+'shex_hq\bin\'
$SavePath7=$SavePath+'shex_wt\bin\'
$SavePath8=$SavePath+'hgt\shhk\bin\'
$SavePath9=$SavePath+'shszcalc\bin\'
$SavePath10=$SavePath+'Options\'
$SavePath11=$SavePath+'stb_hq\bin\'
$SavePath12=$SavePath+'stb_wt\bin\'it

$SaveExe1=$SavePath+'hexinvss_binary\bin\hexinvss.exe'
$SaveExe2=$SavePath+'hexinvss_szhq\bin\hexinvss.exe'
$SaveExe3=$SavePath+'hexinvss_szwt\bin\hexinvss.exe'
$SaveExe4=$SavePath+'hexinvss_skhq\bin\hexinvss.exe'
$SaveExe5=$SavePath+'hexinvss_skwt\bin\hexinvss.exe'
$SaveExe6=$SavePath+'shex_hq\bin\shex.exe'
$SaveExe7=$SavePath+'shex_wt\bin\shex.exe'
$SaveExe8=$SavePath+'hgt\shhk\bin\shhk.exe'
$SaveExe9=$SavePath+'shszcalc\bin\shszcalc.exe'
$SaveExe10=$SavePath+'Options\Options.exe'
$SaveExe11=$SavePath+'stb_hq\bin\stb.exe'
$SaveExe12=$SavePath+'stb_wt\bin\stb.exe'

Start-Sleep -s 1cd $SavePath1start $SaveExe1Start-Sleep -s 1cd $SavePath2start $SaveExe2Start-Sleep -s 1cd $SavePath3start $SaveExe3Start-Sleep -s 1cd $SavePath4start $SaveExe4Start-Sleep -s 1cd $SavePath5start $SaveExe5Start-Sleep -s 1cd $SavePath6start $SaveExe6Start-Sleep -s 1cd $SavePath7start $SaveExe7Start-Sleep -s 1cd $SavePath8start $SaveExe8Start-Sleep -s 1cd $SavePath9start $SaveExe9Start-Sleep -s 1cd $SavePath10start $SaveExe10Start-Sleep -s 1cd $SavePath11start $SaveExe11Start-Sleep -s 1cd $SavePath12start $SaveExe12

相關文章
相關標籤/搜索