同花顺节假日文件更新脚本

相信大家在做同花顺系统运维时候碰到不少重复劳动,如节假日文件,手动更新非常麻烦,可做成如下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'

#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 3

#同花顺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)

#上海个股期权更新,要先关闭程序
#加载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.Text

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

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

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

#启动所有发送
$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\'

$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 1
cd $SavePath1
start $SaveExe1
Start-Sleep -s 1
cd $SavePath2
start $SaveExe2
Start-Sleep -s 1
cd $SavePath3
start $SaveExe3
Start-Sleep -s 1
cd $SavePath4
start $SaveExe4
Start-Sleep -s 1
cd $SavePath5
start $SaveExe5
Start-Sleep -s 1
cd $SavePath6
start $SaveExe6
Start-Sleep -s 1
cd $SavePath7
start $SaveExe7
Start-Sleep -s 1
cd $SavePath8
start $SaveExe8
Start-Sleep -s 1
cd $SavePath9
start $SaveExe9
Start-Sleep -s 1
cd $SavePath10
start $SaveExe10
Start-Sleep -s 1
cd $SavePath11
start $SaveExe11
Start-Sleep -s 1
cd $SavePath12
start $SaveExe12

转载于:https://blog.51cto.com/lysweb/2387209

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值