溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

同花順節(jié)假日文件更新腳本

發(fā)布時(shí)間:2020-07-04 08:02:40 來源:網(wǎng)絡(luò) 閱讀:517 作者:lysweb 欄目:系統(tǒng)運(yùn)維

相信大家在做同花順系統(tǒng)運(yùn)維時(shí)候碰到不少重復(fù)勞動(dòng),如節(jié)假日文件,手動(dòng)更新非常麻煩,可做成如下powershell腳本downholiday.ps1實(shí)現(xiàn)自動(dòng)更新:
#定義參數(shù),各服務(wù)器根據(jù)需要修改此處。
$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所有發(fā)送
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界面發(fā)送節(jié)假日更新腳本
$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)

#上海個(gè)股期權(quán)更新,要先關(guān)閉程序
#加載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()

#啟動(dòng)所有發(fā)送
$SavePath2=$SavePath+'hexinvss_binary\bin\'
$SavePath3=$SavePath+'hexinvss_szhq\bin\'
$SavePath4=$SavePath+'hexinvss_szwt\bin\'
$SavePath5=$SavePath+'hexinvss_skhq\bin\'
$SavePath6=$SavePath+'hexinvss_skwt\bin\'
$SavePath7=$SavePath+'shex_hq\bin\'
$SavePath7=$SavePath+'shex_wt\bin\'
$SavePath8=$SavePath+'hgt\shhk\bin\'
$SavePath9=$SavePath+'shszcalc\bin\'
$SavePath20=$SavePath+'Options\'
$SavePath21=$SavePath+'stb_hq\bin\'
$SavePath22=$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 $SavePath2
start $SaveExe1
Start-Sleep -s 1
cd $SavePath3
start $SaveExe2
Start-Sleep -s 1
cd $SavePath4
start $SaveExe3
Start-Sleep -s 1
cd $SavePath5
start $SaveExe4
Start-Sleep -s 1
cd $SavePath6
start $SaveExe5
Start-Sleep -s 1
cd $SavePath7
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 $SavePath20
start $SaveExe10
Start-Sleep -s 1
cd $SavePath21
start $SaveExe11
Start-Sleep -s 1
cd $SavePath22
start $SaveExe12

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI