![]()
names.wsf
<JOB> <COMMENT> ************************************************************ WEB WSH 実行スケルトン ************************************************************ </COMMENT> <OBJECT id="WshShell" progid="WScript.Shell" /> <SCRIPT language=VBScript> ' *********************************************************** ' 処理開始 ' *********************************************************** nMax = 500 ' *********************************************************** ' Cscript.exe で強制実行 ' *********************************************************** Crun strName1 = "山川森鈴木高田本多村吉岡松丸杉浦中尾安原野内" strName2 = "和元雅正由克友浩春冬洋輝" strName3 = "男也一行樹之" strName4 = "子代美恵" str = "" For i = 1 to nMax ' 姓1文字目 nTarget = Random( 1, Len(strName1) ) strName = Mid( strName1, nTarget, 1 ) ' 1文字目と2文字目が一致したら除外 nTarget2 = nTarget Do while( nTarget = nTarget2 ) nTarget2 = Random( 1, Len(strName1) ) Loop ' 姓2文字目 strName = strName & Mid( strName1, nTarget2, 1 ) & " " ' 名1文字目 nTarget = Random( 1, Len(strName2) ) strName = strName & Mid( strName2, nTarget, 1 ) ' 性別 nTarget = Random( 0, 1 ) ' 性別によって名2文字目を決定 if nTarget = 0 then nTarget = Random( 1, Len(strName3) ) strName = strName & Mid( strName3, nTarget, 1 ) else nTarget = Random( 1, Len(strName4) ) strName = strName & Mid( strName4, nTarget, 1 ) end if str = str & strName & " / " if (i-1) Mod 6 = 5 then Wscript.Echo str str = "" end if Next if str <> "" then Wscript.Echo str end if REM ************************************************ REM 指定範囲の整数の乱数を取得 REM ************************************************ Function Random( nMin, nMax ) Randomize Random = nMin + Int(Rnd * (nMax - nMin + 1)) End function Function SameRandom( nMin, nMax ) SameRandom = nMin + Int(Rnd * (nMax - nMin + 1)) End function REM ********************************************************** REM Wscript で実行された場合は Cscript で実行しなおす REM ********************************************************** Function Crun( ) Dim str str = WScript.FullName str = Right( str, 11 ) str = Ucase( str ) if str <> "CSCRIPT.EXE" then str = WScript.ScriptFullName strParam = " " For I = 0 to Wscript.Arguments.Count - 1 if instr(Wscript.Arguments(I), " ") < 1 then strParam = strParam & Wscript.Arguments(I) & " " else strParam = strParam & Dd(Wscript.Arguments(I)) & " " end if Next Call WshShell.Run( "cmd.exe /c cscript.exe " & Dd(str) & strParam & " & pause", 3 ) WScript.Quit end if End Function REM ********************************************************** REM ダブルクォートで囲む REM ********************************************************** Function Dd( strValue ) Dd = """" & strValue & """" End function </SCRIPT> </JOB>
names.php
<?php
// ソースコードは UTF8N
// PHP.INI の default_charset = "UTF-8"
$NAME_1 = 0;
$NAME_2 = 1;
$NAME_3 = 2;
$NAME_4 = 3;
# シード
$name_seed = array();
$name_seed[] = "山川森鈴木高田本多村吉岡松丸杉浦中尾安原野内";
$name_seed[] = "和元雅正由克友浩春冬洋輝";
$name_seed[] = "男也一行樹之";
$name_seed[] = "子代美恵";
$names = array();
# 人数
$num = 100;
for ( $i = 0; $i < $num; $i++ ) {
// 姓1文字目
$n1 = mb_substr( $name_seed[$NAME_1], rand( 0, mb_strlen($name_seed[$NAME_1])-1 ), 1 );
// 1文字目と2文字目が一致したら除外
$n2 = $n1;
while( $n2 == $n1 ) {
$n2 = mb_substr( $name_seed[$NAME_1], rand( 0, mb_strlen($name_seed[$NAME_1])-1 ), 1 ) ;
}
$name_result = $n1 . $n2 . " ";
// 名1文字目
$n3 = mb_substr( $name_seed[$NAME_2], rand( 0, mb_strlen($name_seed[$NAME_2])-1 ), 1 );
$name_result .= $n3;
$sex = rand( 0,1 );
// 性別によって名2文字目を決定
if ( $sex == 0 ) {
$name_result .= mb_substr( $name_seed[$NAME_3], rand( 0, mb_strlen($name_seed[$NAME_3])-1 ), 1 );
}
else {
$name_result .= mb_substr( $name_seed[$NAME_4], rand( 0, mb_strlen($name_seed[$NAME_4])-1 ), 1 );
}
// php PHP 7.3.13 で化けません
if ( array_search( $name_result, $names ) === FALSE ) {
print $name_result;
}
else {
// 同姓同名
print "*" . $name_result;
}
print " / ";
if ( $i % 6 == 5 ) {
print "\n";
}
$names[] = $name_result;
}
file_put_contents("names.log", print_r($names, true) );
print "\n";
print file_get_contents("names.log");
?>
▼ names.bat( php.exe に対して PATH は通してから実行 )php.exe "%~p0names.php" pauseこのページのPDF
|
|
【VBScriptの最新記事】
- 指定した位置でレジストリエディタを開く為の VBScript をダウンロードします
- VBScript : XCOPYで新しいファイルのみバックアップする為のスクリプトを作成するスクリプト
- VBScript + PowerShell : PowerShell がファイルを開くダイアログで取得したパスをテキストファイル経由で VBScript に戻して使用する
- VBScript : XMLファイルのテキストノードの値の更新
- HTA : 指定したキーでレジストリエディタを開く
- WSH(VBScript) : 指定したキーでレジストリエディタを開く
- VBScript : WEB上のHTMLを使用して、InternetExplorer.Application でパスワード入力を実装する
- VBS : 正規表現で、URL リストの中のドメイン部分のみを取り出す
- 文字列を指定してその名前の変数でオブジェクトを作成する : WEB に VBScript ライブラリ
- 実行中のスクリプトのタイプを知る : WEB に VBScript ライブラリ
- VBS : FileZilla用誰にでも使える拡張子ランチャー



names.wsf




