<?xml version="1.0" encoding="UTF-8" ?>
<feed xml:lang="ja" xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:thr="http://purl.org/syndication/thread/1.0">
  <title type="text">LinuC（Linux技術者認定資格）＆リナックスサーバ構築設定事例</title>
  <subtitle type="html">◆当blogは、Linuxサーバ構築する際の実際の設定手順を個人的メモとして記載しております。LinuC試験の役に立つ情報があるかも…？</subtitle>
  <link rel="self" type="application/atom+xml" href="https://archives.blog-mmo.com/atom"/>
  <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/"/>
  <updated>2010-10-06T19:02:59+09:00</updated>
  <author><name>Account</name></author>
  <generator uri="//www.ninja.co.jp/blog/" version="0.9">忍者ブログ</generator>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />
  <entry>
    <id>archives.blog-mmo.com://entry/197</id>
    <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/shell%20script/%E3%80%90shell%20script%E3%80%91find_copy" />
    <published>2026-10-03T14:26:25+09:00</published> 
    <updated>2026-10-03T14:26:25+09:00</updated> 
    <category term="Shell Script" label="Shell Script" />
    <title>【Shell Script】find_Copy</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<div><span style="font-size: xx-small; color: #808080;">#!/bin/bash</span></div><div></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #808080;"># ルート権限チェック</span></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #0000ff;">if [ "$EUID" -ne 0 ]; then</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; echo "エラー: root権限が必要です（実行キャンセル）"</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; echo "sudo ./$0 で実行してください"</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; exit 1</span></div><div><span style="font-size: xx-small; color: #808080;">fi</span></div><div></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #808080;"># カレントディレクトリ移動</span></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #ff0000;">cd /tmp/TEST ; pwd</span></div><div></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #808080;"># ユーザー入力を変数にセット</span></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #808080;">echo "*** コピー対象の指定 ***"</span></div><div><span style="font-size: xx-small; color: #0000ff;">read -p "1. 対象のパターン文字列 (例: xxx*): " <strong>DIR_PATTERN</strong></span></div><div><span style="font-size: xx-small; color: #0000ff;">read -p "2. 対象の年 (例: 2026): " <strong>YEAR</strong></span></div><div><span style="font-size: xx-small; color: #0000ff;">read -p "3. 対象の月 (例: 09): " <strong>MONTH</strong></span></div><div></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #808080;"># 空入力チェック</span></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #808080;">if [ -z "$DIR_PATTERN" ] || [ -z "$YEAR" ] || [ -z "$MONTH" ]; then</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; echo "エラー: すべての項目を入力してください（処理中断）"</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; exit 1</span></div><div><span style="font-size: xx-small; color: #808080;">fi</span></div><div></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #808080;"># 月の入力形式の補正</span></div><div><span style="font-size: xx-small; color: #808080;"># (例: "9" の場合 "09" に補正)</span></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #808080;">if [[ ${#MONTH} -eq 1 ]]; then</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; MONTH="0${MONTH}"</span></div><div><span style="font-size: xx-small; color: #808080;">fi</span></div><div></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #808080;"># 月末日付の自動判定</span></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #0000ff;">case "$MONTH" in</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <span style="color: #0000ff;">"01"|"03"|"05"|"07"|"08"|"10"|"12")</span></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; DAY_RANGE="3[0-1]"</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; ;;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <span style="color: #0000ff;">"04"|"06"|"09"|"11")</span></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; DAY_RANGE="30"</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; ;;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;<span style="color: #0000ff;"> "02")</span></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; # うるう年判定</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; <span style="color: #0000ff;">if (( (YEAR % 4 == 0 &amp;&amp; YEAR % 100 != 0) || YEAR % 400 == 0 )); then</span></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; DAY_RANGE="2[0-9]"</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; <span style="color: #0000ff;">else</span></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; DAY_RANGE="2[0-8]"</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; <span style="color: #0000ff;">fi</span></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; ;;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <span style="color: #0000ff;">*)</span></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; echo "エラー: 月の入力不正(01〜12以外は不正)"</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; exit 1</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; ;;</span></div><div><span style="font-size: xx-small; color: #0000ff;">esac</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">echo ""</span></div><div><span style="font-size: xx-small; color: #808080;">echo "*** コピー処理（開始） ***"</span></div><div><span style="font-size: xx-small; color: #808080;">echo "【検索元】カレントディレクトリ ( $(pwd) )"</span></div><div><span style="font-size: xx-small; color: #808080;">echo "【ディレクトリ条件】./${DIR_PATTERN}"</span></div><div><span style="font-size: xx-small; color: #808080;">echo "【対象日時】${YEAR}年${MONTH}月 (日最大範囲:${DAY_RANGE})"</span></div><div><span style="font-size: xx-small; color: #808080;">echo "***************************"</span></div><div></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #808080;"># カレントディレクトリ配下でループ</span></div><div><span style="font-size: xx-small; color: #808080;"># （パターン文字列に一致する場合）</span></div><div><span style="font-size: xx-small; color: #808080;"># ============================</span></div><div><span style="font-size: xx-small; color: #0000ff;">find . -maxdepth 1 -type d -name "${DIR_PATTERN}" | while read -r src_dir; do</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; # ディレクトリ名のみ抽出</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; dir_name=$(basename "$src_dir")</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <span style="color: #ff0000;">dest_dir=<strong>"/tmp/$dir_name"</strong></span></span></div><div></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; echo "（コピー中）: $src_dir -&gt; $dest_dir"</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; # ============================</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; # コピー先のディレクトリ作成（既存はスキップ）</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; mkdir -p "$dest_dir"</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; # ============================</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; # 対象ファイルのコピー実行（1万件以上でも可）</span></div><div><span style="font-size: xx-small; color: #0000ff;">&nbsp;<strong> find "$src_dir" -maxdepth 1 -type f -regextype posix-egrep \</strong></span></div><div><strong><span style="font-size: xx-small; color: #0000ff;">&nbsp; &nbsp; -regex ".*/[^/]*_${YEAR}-?(${MONTH}-?(0[1-9]|[1-2][0-9]|${DAY_RANGE}))_[^/]*" \</span></strong></div><div><strong><span style="font-size: xx-small; color: #0000ff;">&nbsp; &nbsp; -exec cp -a -t "$dest_dir" {} +</span></strong></div><div><span style="font-size: xx-small; color: #808080;">done</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">echo "*** コピー処理（完了） ***"</span></div>]]> 
    </content>
    <author>
            <name>Account</name>
        </author>
  </entry>
  <entry>
    <id>archives.blog-mmo.com://entry/196</id>
    <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/linux%20%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89/%E3%80%90linux%E3%80%91%E6%97%A5%E4%BB%98%E6%8C%87%E5%AE%9A%E3%81%AE%E5%9C%A7%E7%B8%AE" />
    <published>2026-08-29T12:45:42+09:00</published> 
    <updated>2026-08-29T12:45:42+09:00</updated> 
    <category term="Linux コマンド" label="Linux コマンド" />
    <title>【Linux】日付指定の圧縮</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<div><strong><span style="font-size: xx-small; color: #808080;">【以下の条件で圧縮】</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">&nbsp;・yyyymmdd と yyyy-mm-dd の両方の形式</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">&nbsp;・日付の範囲（8/3～8/31の例）</span></strong></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><strong><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp;tar <span style="color: #0000ff;">-czvf</span> logs-aug.tar.gz <span style="color: #0000ff;"><span style="color: #ff0000;">*</span>_202608<span style="color: #ff0000;">{<span style="color: #3366ff;">03</span>..<span style="color: #3366ff;">31</span>}</span>_<span style="color: #ff0000;">*</span></span> <span style="color: #0000ff;"><span style="color: #ff0000;">*</span>_2026-08-<span style="color: #ff0000;">{<span style="color: #3366ff;">03</span>..<span style="color: #3366ff;">31</span>}</span>_<span style="color: #ff0000;">*</span></span> <span style="color: #3366ff;">2&gt; /dev/null</span></span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp;zip <span style="color: #0000ff;">-r</span> logs-aug.tar.gz.zip <span style="color: #0000ff;"><span style="color: #ff0000;">*</span>_202608<span style="color: #ff0000;">{<span style="color: #3366ff;">03</span>..<span style="color: #3366ff;">31</span>}</span>_<span style="color: #ff0000;">*</span></span> <span style="color: #0000ff;"><span style="color: #ff0000;">*</span>_2026-08-<span style="color: #ff0000;">{<span style="color: #3366ff;">03</span>..<span style="color: #3366ff;">31</span>}</span>_<span style="color: #ff0000;">*</span></span> <span style="color: #3366ff;">2&gt; /dev/null</span></span></strong></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><strong><span style="font-size: xx-small; color: #808080;">【圧縮した内容の確認】</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp;tar <span style="color: #0000ff;">-tzf</span> logs-aug.tar.gz<span style="color: #0000ff;"> | head -n 20</span></span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp;unzip <span style="color: #0000ff;">-l</span> logs-aug.zip<span style="color: #0000ff;"> | head -n 20</span></span></strong></div>]]> 
    </content>
    <author>
            <name>Account</name>
        </author>
  </entry>
  <entry>
    <id>archives.blog-mmo.com://entry/195</id>
    <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/vba/%E3%80%90vba%E3%80%91%E5%88%97%E7%B5%90%E5%90%88" />
    <published>2026-08-21T11:38:03+09:00</published> 
    <updated>2026-08-21T11:38:03+09:00</updated> 
    <category term="VBA" label="VBA" />
    <title>【VBA】列結合</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<div><span style="font-size: xx-small; color: #808080;">Sub CombineCSVColumnsFromList()</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【変数定義】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Dim fso As Object</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Dim scriptPath As String, listPath As String</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Dim ts As Object, line As String</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Dim csvFiles() As String, fileCount As Long</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Dim i As Long, r As Long</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Dim currentBook As Workbook, targetSheet As Worksheet</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Dim csvBook As Workbook, csvSheet As Worksheet</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Dim lastRow As Long, maxRow As Long</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Dim firstFileName As String, nextFileName As String</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Dim currentDate As String, excelFileName As String</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#① マクロを実行しているExcelファイルと</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#同じフォルダーのパスを取得</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Set fso = CreateObject("Scripting.FileSystemObject")</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; scriptPath = ThisWorkbook.Path</span></div><div><strong><span style="font-size: xx-small; color: #808080;">&nbsp; listPath = fso.BuildPath(scriptPath, "<span style="color: #ff0000;">list.txt</span>") <span style="color: #008000;">'● リストファイルのパス取得</span></span></strong></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【リストファイルの存在チェック】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; If Not fso.FileExists(listPath) Then</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; <strong>MsgBox "エラー: リストファイル無し", vbCritical</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; Exit Sub</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; End If</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#② リストファイルから対象CSVのフルパス読込</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; fileCount = 0</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Set ts = fso.OpenTextFile(listPath, 1) <span style="color: #008000;">'● 1 = ForReading</span></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Do Until ts.AtEndOfStream</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; line = Trim(ts.ReadLine)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; If line &lt;&gt; "" Then</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim fullPath As String</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fullPath = fso.BuildPath(scriptPath, line)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If fso.FileExists(fullPath) Then</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReDim Preserve csvFiles(fileCount)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; csvFiles(fileCount) = fullPath</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fileCount = fileCount + 1</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; End If</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Loop</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; ts.Close</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【ファイル数のチェック】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; If fileCount &lt; 2 Then</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; <strong>MsgBox "エラー: 対象CSVファイルが２個未満", vbCritical</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; Exit Sub</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; End If</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【エラーハンドリング開始】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <span style="color: #0000ff;"><strong>On Error GoTo ErrorHandler</strong></span></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【処理速度の高速化】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【画面更新、警告、自動計算をオフ】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <strong><span style="color: #0000ff;">Application.ScreenUpdating = False</span></strong></span></div><div><strong><span style="font-size: xx-small; color: #0000ff;">&nbsp; Application.DisplayAlerts = False</span></strong></div><div><strong><span style="font-size: xx-small; color: #0000ff;">&nbsp; Application.Calculation = xlCalculationManual</span></strong></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#③ 新しいワークブックを作成</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#書き込み対象のシートを設定</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Set currentBook = Workbooks.Add(xlWBATWorksheet)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Set targetSheet = currentBook.Sheets(1)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#④ 1番目のCSVファイルを処理</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#(1列目[A列] と *列目[*列] を抽出)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; firstFileName = fso.GetBaseName(csvFiles(0))</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Set csvBook = Workbooks.Open(csvFiles(0))</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Set csvSheet = csvBook.Sheets(1)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; lastRow = csvSheet.Cells(csvSheet.Rows.Count, "A").End(xlUp).Row</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; maxRow = lastRow <span style="color: #008000;">'● 基準となる行数を保持</span></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【ヘッダーの書き込み】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; targetSheet.Cells(1, 1).Value = "Col1"</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; targetSheet.Cells(1, 2).Value = firstFileName</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【データのコピー】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#１個目のCSVファイルの１列、Ｎ列</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; For r = 1 To maxRow</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp;<strong>targetSheet.Cells(r + 1, 1).Value = csvSheet.Cells(r, 1).Value '● 1列/A列 (H0)</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#targetSheet.Cells(r + 1, 2).Value = csvSheet.Cells(r, 2).Value '● 2列/B列 (H1)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp;<strong>targetSheet.Cells(r + 1, 2).Value = csvSheet.Cells(r, 3).Value '● 3列/C列 (H2)</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#targetSheet.Cells(r + 1, 2).Value = csvSheet.Cells(r, 4).Value '● 4列/D列 (H3)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#targetSheet.Cells(r + 1, 2).Value = csvSheet.Cells(r, 5).Value '● 5列/E列 (H4)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Next r</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; csvBook.Close SaveChanges:=False</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#⑤ ２個目以降のCSVファイルを処理</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#(*列目[*列] のみを横に結合)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; For i = 1 To fileCount - 1</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; nextFileName = fso.GetBaseName(csvFiles(i))</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; Set csvBook = Workbooks.Open(csvFiles(i))</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; Set csvSheet = csvBook.Sheets(1)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【ヘッダーの書き込み】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#(C列、D列&hellip;と右へ追加)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; targetSheet.Cells(1, i + 2).Value = nextFileName</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【データのコピー】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#２個目のCSVファイルのＮ列</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; For r = 1 To maxRow</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; '#targetSheet.Cells(r + 1, i + 2).Value = csvSheet.Cells(r, 2).Value '● 2列/B列 (H1)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<strong>targetSheet.Cells(r + 1, i + 2).Value = csvSheet.Cells(r, 3).Value '● 3列/C列 (H2)</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; '#targetSheet.Cells(r + 1, i + 2).Value = csvSheet.Cells(r, 4).Value '● 4列/D列 (H3)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; '#targetSheet.Cells(r + 1, i + 2).Value = csvSheet.Cells(r, 5).Value '● 5列/E列 (H4)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; Next r</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; csvBook.Close SaveChanges:=False</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; Next i</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#⑥ 列幅の自動調整 (AutoFit)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <strong>targetSheet.UsedRange.Columns.AutoFit</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#⑦ ファイル名を指定して保存</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#Excel 97-2003形式(.xls)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; currentDate = Format(Date, "yyyyMMdd")</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <strong>excelFileName = "_" &amp; <span style="color: #0000ff;">firstFileName</span> &amp; "_" &amp; <span style="color: #0000ff;">currentDate</span> &amp; "<span style="color: #ff0000;">_★</span>" &amp; ".xls"</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【xlExcel8 = 56】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#(Excel 97-2003 ブック形式)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <strong>currentBook.SaveAs Filename:=fso.BuildPath(scriptPath, excelFileName), FileFormat:=<span style="color: #0000ff;">56</span></strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; currentBook.Close SaveChanges:=False</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <strong>MsgBox "【処理完了】" &amp; vbCrLf &amp; excelFileName, vbInformation</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">'#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">'#【終了処理】</span></div><div><span style="font-size: xx-small; color: #808080;">'#（ExitProcedure）</span></div><div><span style="font-size: xx-small; color: #808080;">'#**********************&nbsp;</span></div><div><strong><span style="font-size: xx-small; color: #0000ff;">ExitProcedure:</span></strong></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#画面更新、警告、自動計算を元に戻す</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <strong><span style="color: #0000ff;">Application.ScreenUpdating = True</span></strong></span></div><div><strong><span style="font-size: xx-small; color: #0000ff;">&nbsp; Application.DisplayAlerts = True</span></strong></div><div><strong><span style="font-size: xx-small; color: #0000ff;">&nbsp; Application.Calculation = xlCalculationAutomatic</span></strong></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <strong>Exit Sub</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">'#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">'#【エラーハンドリング処理を実行】</span></div><div><span style="font-size: xx-small; color: #808080;">'#（ErrorHandler）</span></div><div><span style="font-size: xx-small; color: #808080;">'#**********************&nbsp;</span></div><div><span style="color: #0000ff;"><strong><span style="font-size: xx-small;">ErrorHandler:</span></strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <strong>MsgBox "【予期せぬエラー発生の為、処理中断】" &amp; vbCrLf &amp; _</strong></span></div><div><strong><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"エラー番号: " &amp; Err.Number &amp; vbCrLf &amp; _</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"エラー内容: " &amp; Err.Description, vbCritical</span></strong></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【開きっぱなしのCSVや作成中ファイルを閉じる】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#（必要に応じて実行）</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <strong>On Error Resume Next</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; If Not csvBook Is Empty Then csvBook.Close SaveChanges:=False</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; If Not currentBook Is Empty Then currentBook.Close SaveChanges:=False</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#【終了処理（ExitProcedure）へ移動】</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; '#**********************&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; <strong><span style="color: #0000ff;">Resume ExitProcedure</span></strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">End Sub</span></div>]]> 
    </content>
    <author>
            <name>Account</name>
        </author>
  </entry>
  <entry>
    <id>archives.blog-mmo.com://entry/194</id>
    <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/powershell/%E3%80%90powershell%E3%80%91%E5%88%97%E7%B5%90%E5%90%88" />
    <published>2026-08-21T11:22:11+09:00</published> 
    <updated>2026-08-21T11:22:11+09:00</updated> 
    <category term="PowerShell" label="PowerShell" />
    <title>【PowerShell】列結合</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<div><strong><span style="font-size: xx-small; color: #808080;">****************************************************</span></strong><br />
<span style="color: #0000ff;"><strong><span style="font-size: xx-small;">&nbsp; powershell -ExecutionPolicy Bypass -File "列結合.ps1"<br />
</span></strong></span><span style="font-size: xx-small;">&nbsp; <strong>（list.txtに記載したファイル名を対象に列結合する）</strong></span><br />
<strong><span style="font-size: xx-small; color: #808080;">****************************************************</span></strong><br />
<span style="font-size: xx-small; color: #808080;">$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path</span></div><div><span style="font-size: xx-small; color: #ff0000;">$listPath = Join-Path $scriptPath <strong>"list.txt"</strong></span></div><div></div><div><span style="font-size: xx-small; color: #808080;">if (-not (Test-Path $listPath)) {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; Write-Error "Error: list.txt not found."</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; exit</span></div><div><span style="font-size: xx-small; color: #808080;">}</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">$csvLines = Get-Content -LiteralPath $listPath</span></div><div><span style="font-size: xx-small; color: #808080;">$csvFiles = @()</span></div><div><span style="font-size: xx-small; color: #808080;">foreach ($line in $csvLines) {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; if (-not [string]::IsNullOrWhiteSpace($line)) {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; $cleanLine = $line.Trim()</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; $fullPath = Join-Path $scriptPath $cleanLine</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; if (Test-Path $fullPath) {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $csvFiles += Get-Item -LiteralPath $fullPath</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; }</span></div><div><span style="font-size: xx-small; color: #808080;">}</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">if ($csvFiles.Count -lt 2) {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; Write-Error "Error: Needs 2 or more valid CSV files from list.txt."</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; exit</span></div><div><span style="font-size: xx-small; color: #808080;">}</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">$headers = 0..99 | ForEach-Object { "H$_" }</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">$firstCsv = Import-Csv -LiteralPath $csvFiles[0].FullName -Header $headers</span></div><div><span style="font-size: xx-small; color: #808080;">$baseCsv = @()</span></div><div><span style="font-size: xx-small; color: #808080;">$firstFileName = [string]$csvFiles[0].BaseName</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">foreach ($row in $firstCsv) {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $properties = [ordered]@{</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; "Col1"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = $row.H0</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; $firstFileName = $row.H2</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; }</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $baseCsv += New-Object PSObject -Property $properties</span></div><div><span style="font-size: xx-small; color: #808080;">}</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">for ($fileIdx = 1; $fileIdx -lt $csvFiles.Count; $fileIdx++) {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $nextCsv = Import-Csv -LiteralPath $csvFiles[$fileIdx].FullName -Header $headers</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $nextFileName = [string]$csvFiles[$fileIdx].BaseName</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp;&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; for ($rowIdx = 0; $rowIdx -lt $baseCsv.Count; $rowIdx++) {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; $nextValue = $nextCsv[$rowIdx].H2</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; $baseCsv[$rowIdx] | Add-Member -MemberType NoteProperty -Name $nextFileName -Value $nextValue -Force</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; }</span></div><div><span style="font-size: xx-small; color: #808080;">}</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">$tempCsv = "$scriptPath\temp_combined.csv"</span></div><div><span style="font-size: xx-small; color: #808080;">$baseCsv | Export-Csv -LiteralPath $tempCsv -NoTypeInformation -Encoding utf8</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">$currentDate = Get-Date -Format "yyyyMMdd"</span></div><div><span style="font-size: xx-small; color: #808080;">$excelFileName = "OUTPUT_${firstFileName}_${currentDate}.xls"</span></div><div><span style="font-size: xx-small; color: #808080;">$excelPath = Join-Path $scriptPath $excelFileName</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">try {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $excel = New-Object -ComObject Excel.Application</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $excel.Visible = $false</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $excel.DisplayAlerts = $false</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $workbook = $excel.Workbooks.Open($tempCsv)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $worksheet = $workbook.Sheets.Item(1)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $worksheet.UsedRange.Columns.AutoFit() | Out-Null</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $workbook.SaveAs($excelPath, 56)</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; $workbook.Close()</span></div><div><span style="font-size: xx-small; color: #808080;">}</span></div><div><span style="font-size: xx-small; color: #808080;">finally {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; if ($excel) {</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; $excel.Quit()</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; [System.Runtime.InteropServices.Marshal]::ReleaseComObject($excel) | Out-Null</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; &nbsp; &nbsp; Remove-Variable excel -ErrorAction SilentlyContinue</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; }</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp; &nbsp; if (Test-Path $tempCsv) { Remove-Item $tempCsv }</span></div><div><span style="font-size: xx-small; color: #808080;">}</span></div>]]> 
    </content>
    <author>
            <name>Account</name>
        </author>
  </entry>
  <entry>
    <id>archives.blog-mmo.com://entry/193</id>
    <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/windows%20script/%E3%80%90bat%E3%80%91winscp%E5%AE%9F%E8%A1%8C" />
    <published>2026-08-11T13:00:53+09:00</published> 
    <updated>2026-08-11T13:00:53+09:00</updated> 
    <category term="Windows Script" label="Windows Script" />
    <title>【BAT】WinSCP実行</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<div><span style="color: #808080; font-size: xx-small;">@echo off</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # 変数定義</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;"><strong>set "TERATERM_DIR=C:\teraterm-5.4.1"</strong></span></div><div><span style="color: #808080; font-size: xx-small;"><strong>set "WINSCP_DIR=C:\WinSCP-6.5.6-Portable"</strong></span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">color 8a</span></div><div><span style="color: #808080; font-size: xx-small;">echo *************************</span></div><div><span style="color: #808080; font-size: xx-small;">echo TERATERM_DIR</span></div><div><span style="color: #808080; font-size: xx-small;">echo *************************</span></div><div><span style="color: #808080; font-size: xx-small;">echo WINSCP_DIR</span></div><div><span style="color: #808080; font-size: xx-small;">echo *************************</span></div><div><span style="color: #808080; font-size: xx-small;">timeout 2</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # メニュー画面の選択処理</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">:MENU</span></div><div><span style="color: #808080; font-size: xx-small;">cls</span></div><div><span style="color: #808080; font-size: xx-small;">color 02</span></div><div><span style="color: #808080; font-size: xx-small;">echo ====================================</span></div><div><span style="color: #808080; font-size: xx-small;">echo&nbsp; &nbsp;メニュー：実行する処理を選んでください</span></div><div><span style="color: #808080; font-size: xx-small;">echo ====================================</span></div><div><strong><span style="color: #808080; font-size: xx-small;">echo&nbsp; [1] Tera Term接続</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">echo&nbsp; [2] WinSCP接続</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">echo&nbsp; [q] 終了</span></strong></div><div><span style="color: #808080; font-size: xx-small;">echo ====================================</span></div><div><span style="color: #808080; font-size: xx-small;">echo.</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">set /p CHOICE="メニューから選択 : "</span></div><div><span style="color: #808080; font-size: xx-small;"><strong>if "%CHOICE%"=="1" goto RUN_01</strong></span></div><div><span style="color: #808080; font-size: xx-small;"><strong>if "%CHOICE%"=="2" goto RUN_02</strong></span></div><div><span style="color: #808080; font-size: xx-small;"><strong>if "%CHOICE%"=="q" goto TARGET_EXIT</strong></span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # 入力エラー処理</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">color 04</span></div><div><span style="color: #808080; font-size: xx-small;">echo 不正な入力です。1から3の数字を入力してください。</span></div><div><span style="color: #808080; font-size: xx-small;">pause</span></div><div><span style="color: #808080; font-size: xx-small;">goto MENU</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # 処理（１）</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">:RUN_01</span></div><div><span style="color: #808080; font-size: xx-small;">color 09</span></div><div><span style="color: #808080; font-size: xx-small;">echo Tera Term マクロを起動</span></div><div><span style="color: #808080; font-size: xx-small;"><strong>"%TERATERM_DIR%\<span style="color: #0000ff;">ttpmacro.exe</span>"</strong><strong>&nbsp;<span style="color: #0000ff;">"%USERPROFILE%\Desktop\<span style="color: #ff0000;">LOGIN.ttl</span>"</span></strong></span></div><div><span style="color: #808080; font-size: xx-small;">goto TARGET_END</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # 処理（２）</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">:RUN_02</span></div><div><span style="color: #808080; font-size: xx-small;">color 09</span></div><div><span style="color: #808080; font-size: xx-small;">echo WinSCP を起動</span></div><div><span style="color: #808080; font-size: xx-small;"><strong>"%WINSCP_DIR%\<span style="color: #0000ff;">WinSCP.exe</span>" <span style="color: #0000ff;">sftp://<span style="color: #ff0000;">&lt;ユーザ&gt;</span>:<span style="color: #ff0000;">&lt;パスワード&gt;</span>@<span style="color: #ff0000;">192.168.0.xx</span>/ /rawsettings SshHostKeyPolicy=ad-hoc</span></strong></span></div><div><span style="color: #808080; font-size: xx-small;">goto TARGET_END</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # メニュー画面へ遷移</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">:TARGET_END</span></div><div><span style="color: #808080; font-size: xx-small;">color 08</span></div><div><span style="color: #808080; font-size: xx-small;">echo.</span></div><div><span style="color: #808080; font-size: xx-small;">echo メニューに戻ります。</span></div><div><span style="color: #808080; font-size: xx-small;">timeout 2</span></div><div><span style="color: #808080; font-size: xx-small;">goto MENU</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # 終了処理</span></div><div><span style="color: #808080; font-size: xx-small;">REM #*************************</span></div><div><span style="color: #808080; font-size: xx-small;">:TARGET_EXIT</span></div><div><span style="color: #808080; font-size: xx-small;">color 07</span></div><div><span style="color: #808080; font-size: xx-small;">echo 終了</span></div><div><span style="color: #808080; font-size: xx-small;">timeout 2</span></div>]]> 
    </content>
    <author>
            <name>Account</name>
        </author>
  </entry>
  <entry>
    <id>archives.blog-mmo.com://entry/192</id>
    <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/linux%20%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89/%E3%80%90linux%E3%80%91bracketed%20paste%20mode" />
    <published>2026-07-18T15:32:52+09:00</published> 
    <updated>2026-07-18T15:32:52+09:00</updated> 
    <category term="Linux コマンド" label="Linux コマンド" />
    <title>【Linux】Bracketed Paste Mode</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<div><span style="color: #808080;"><strong><span style="font-size: xx-small;">Bracketed Paste Mode</span></strong></span><br />
<span style="color: #808080;"><strong><span style="font-size: xx-small;">&nbsp;&rArr; コマンドのペースト投入で回避する方法</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">&nbsp;</span></strong></span></div><div><span style="color: #333333;"><strong><span style="font-size: xx-small;">① 一時的に無効化する場合</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">（現在のターミナル画面を閉じると設定はリセットされる）</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">&nbsp;<span style="color: #0000ff;">bind 'set enable-bracketed-paste <span style="color: #ff0000;">off</span>'</span></span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">&nbsp;</span></strong></span></div><div><span style="color: #333333;"><strong><span style="font-size: xx-small;">② 恒久的に無効化する場合</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">&nbsp;&rArr; <span style="color: #0000ff;">TERATERM.INI</span>に以下を設定する</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">BracketedSupport=<span style="color: #ff0000;">off</span></span></span></strong></span></div>]]> 
    </content>
    <author>
            <name>Account</name>
        </author>
  </entry>
  <entry>
    <id>archives.blog-mmo.com://entry/191</id>
    <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/linux%20%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89/%E3%80%90linux%E3%80%91ubuntu%E8%A8%AD%E5%AE%9A" />
    <published>2026-06-07T19:51:32+09:00</published> 
    <updated>2026-06-07T19:51:32+09:00</updated> 
    <category term="Linux コマンド" label="Linux コマンド" />
    <title>【Linux】Ubuntu設定</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<div><strong><span style="color: #808080; font-size: xx-small;">#*****************************</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;"># ■ アップデート</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">#*****************************</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">sudo <span style="color: #ff0000;">apt</span> <span style="color: #0000ff;">update</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">sudo <span style="color: #ff0000;">apt</span> <span style="color: #0000ff;">upgrade</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">sudo <span style="color: #ff0000;">apt</span> <span style="color: #0000ff;">dist-upgrade</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">sudo <span style="color: #ff0000;">apt</span> <span style="color: #0000ff;">autoremove</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">sudo <span style="color: #0000ff;">reboot</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp;</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">#*****************************</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;"># ■ SSH設定</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">#*****************************</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">sudo <span style="color: #ff0000;">apt</span> <span style="color: #0000ff;">install ssh</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">sudo <span style="color: #ff0000;">systemctl</span> <span style="color: #0000ff;">start ssh</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">sudo <span style="color: #ff0000;">systemctl</span> <span style="color: #0000ff;">status ssh</span></span></strong></div>]]> 
    </content>
    <author>
            <name>Account</name>
        </author>
  </entry>
  <entry>
    <id>archives.blog-mmo.com://entry/190</id>
    <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/windows%20script/%E3%80%90ttl%E3%80%91listbox%E3%83%AD%E3%82%B0%E3%82%A4%E3%83%B3%E2%91%A1" />
    <published>2026-06-06T11:12:12+09:00</published> 
    <updated>2026-06-06T11:12:12+09:00</updated> 
    <category term="Windows Script" label="Windows Script" />
    <title>【TTL】ListBoxログイン②</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<div><span style="font-size: xx-small; color: #808080;"><strong>&nbsp; ※※※※※※※※※※※※※※</strong></span></div><div><span style="font-size: xx-small; color: #808080;"><strong>&nbsp; ※※※ TTL_ログイン.ttl ※※</strong></span></div><div><span style="font-size: xx-small; color: #808080;"><strong>&nbsp; ※※※※※※※※※※※※※※</strong></span></div><div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ 対象サーバ情報</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><strong><span style="font-size: xx-small; color: #808080;">strdim Server_NAME 4</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_NAME[0] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ｻｰﾊﾞ名】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_NAME[1] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ｻｰﾊﾞ名】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_NAME[2] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ｻｰﾊﾞ名】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_NAME[3] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ｻｰﾊﾞ名】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strdim Server_IPaddress 4</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_IPaddress[0] = '192.168.0.xx'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_IPaddress[1] = '192.168.0.xx'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_IPaddress[2] = '192.168.0.xx'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_IPaddress[3] = '192.168.0.xx'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strdim Server_USER 4</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_USER[0] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ﾕｰｻﾞID】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_USER[1] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ﾕｰｻﾞID】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_USER[2] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ﾕｰｻﾞID】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_USER[3] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ﾕｰｻﾞID】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strdim Server_PASS 4</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_PASS[0] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ﾊﾟｽﾜｰﾄﾞ】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_PASS[1] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ﾊﾟｽﾜｰﾄﾞ】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_PASS[2] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ﾊﾟｽﾜｰﾄﾞ】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">Server_PASS[3] = '</span></strong><span color="#808080" style="color: #808080;"><span style="font-size: xx-small;"><b>【ﾊﾟｽﾜｰﾄﾞ】</b></span></span><strong><span style="font-size: xx-small; color: #808080;">'</span></strong></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ サーバ選択画面</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #0000ff;">getdir TTL_Path</span></div><div><span style="font-size: xx-small; color: #0000ff;">strconcat TTL_Path '\TTL_SSH.ttl'</span></div><div><span style="color: #ff0000;"><strong><span style="font-size: xx-small;">include <span style="color: #0000ff;">TTL_Path</span></span></strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ ログイン後にコマンド実行</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">pause 1</span></div><div><span style="font-size: xx-small; color: #808080;">sendln</span></div><div><span style="font-size: xx-small; color: #808080;">sendln</span></div><div><span style="font-size: xx-small; color: #808080;">wait '$' '#'</span></div><div><span style="font-size: xx-small; color: #808080;">sendln</span></div><div><span style="font-size: xx-small; color: #808080;">send 'date ; uname -n ; id'</span></div><div><span style="font-size: xx-small; color: #808080;">sendln</span></div><div><span style="font-size: xx-small; color: #808080;">sendln</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;"><strong>&nbsp; ※※※※※※※※※※※※※※</strong></span></div><div><span style="font-size: xx-small; color: #808080;"><strong>&nbsp; ※※※※TTL_SSH.ttl ※※※※</strong></span></div><div><span style="font-size: xx-small; color: #808080;"><strong>&nbsp; ※※※※※※※※※※※※※※</strong></span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ 選択画面の表示</span></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><strong><span style="font-size: xx-small; color: #ff0000;">listbox '『対象を選択してください』' '【サーバ名】' <span style="color: #0000ff;">Server_NAME</span></span></strong></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><span style="font-size: xx-small; color: #808080;">;■ 選択したresult値を取得</span></div><div><span style="font-size: xx-small; color: #ff0000;">if result &gt;= 0 then</span></div><div><span style="font-size: xx-small; color: #0000ff;">&nbsp; paramIP = Server_IPaddress[result] ;; ■ IPアドレス</span></div><div><span style="font-size: xx-small; color: #0000ff;">&nbsp; paramUSER = Server_USER[result]&nbsp; &nbsp; ;; ■ ユーザ名</span></div><div><span style="font-size: xx-small; color: #0000ff;">&nbsp; paramPASS = Server_PASS[result]&nbsp; &nbsp; ;; ■ パスワード</span></div><div><span style="font-size: xx-small; color: #0000ff;">&nbsp; LOG_File = Server_NAME[result]&nbsp; &nbsp; &nbsp;;; ■ ログファイル名</span></div><div><span style="font-size: xx-small; color: #ff0000;">else</span></div><div><span style="font-size: xx-small; color: #ff0000;">&nbsp; end</span></div><div><span style="font-size: xx-small; color: #ff0000;">endif</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ SSHログイン情報</span></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><span style="font-size: xx-small; color: #808080;">;■ SSHの認証方式の設定</span></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><span style="font-size: xx-small; color: #808080;">paramAUTH = 'password'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;; ■ 認証方式の値</span></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><span style="font-size: xx-small; color: #808080;">;■ INIファイルのパス設定</span></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><span style="font-size: xx-small; color: #808080;">getdir macroDIR&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ 現在のパス取得</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat macroDIR '\TERATERM.INI'&nbsp; &nbsp;;; ■ INIファイル名</span></div><div><span style="font-size: xx-small; color: #808080;">paramINI = macroDIR&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ INIファイルの値</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ SSH接続コマンド編集</span></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><span style="font-size: xx-small; color: #808080;">LoginSSH = paramIP&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ IPアドレス</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH ':22 /ssh /2 /auth=' ;; ■ 認証方式オプション</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH paramAUTH&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ 認証方式の値</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH ' /user='&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ ユーザ名オプション</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH paramUSER&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ ユーザ名の値</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH ' /passwd='&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ パスワードオプション</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH paramPASS&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ パスワードの値</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH ' /F='&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;; ■ INIファイルオプション</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH paramINI&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;; ■ INIファイルの値</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ LOGファイルの設定</span></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><span style="font-size: xx-small; color: #808080;">getdir LOG_Path</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LOG_Path '\LOG\'</span></div><div><span style="font-size: xx-small; color: #808080;">getdate LogDate '_%Y%m%d-%H%M%S.log'</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LOG_File LogDate</span></div><div><span style="font-size: xx-small; color: #808080;">strconcat LOG_Path LOG_File</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ SSH接続ログイン</span></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><span style="font-size: xx-small; color: #808080;">;; messagebox LOG_Path 'デバッグ用メッセージ'</span></div><div><span style="font-size: xx-small; color: #0000ff;">connect LoginSSH</span></div><div><span style="font-size: xx-small; color: #0000ff;">logopen LOG_Path 0 0</span></div><div><span style="font-size: xx-small; color: #808080;">&nbsp;</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ タイトル設定</span></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><span style="font-size: xx-small; color: #808080;">settitle LOG_Path</span></div>]]> 
    </content>
    <author>
            <name>Account</name>
        </author>
  </entry>
  <entry>
    <id>archives.blog-mmo.com://entry/189</id>
    <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/windows%20script/%E3%80%90ttl%E3%80%91listbox%E3%83%AD%E3%82%B0%E3%82%A4%E3%83%B3%E2%91%A0" />
    <published>2026-05-23T14:58:04+09:00</published> 
    <updated>2026-05-23T14:58:04+09:00</updated> 
    <category term="Windows Script" label="Windows Script" />
    <title>【TTL】ListBoxログイン①</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ SSHログイン情報</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;"><strong><span style="color: #0000ff;">paramUSER = '<span style="color: #ff0000;">&lt;ユーザ名&gt;</span>'&nbsp;</span></strong> &nbsp; &nbsp; ;; ■ ユーザ名の値</span></div><div><span style="font-size: xx-small; color: #808080;"><strong><span style="color: #0000ff;">paramPASS = '<span style="color: #ff0000;">&lt;パスワード&gt;</span>'&nbsp;</span></strong> &nbsp; ;; ■ パスワードの値</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ SSHの認証方式の設定</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">paramAUTH = 'password'&nbsp; &nbsp; &nbsp; &nbsp; ;; ■ 認証方式の値</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ INIファイルのパス設定</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">getdir macroDIR&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ 現在のパス取得</span></div><div><span style="font-size: xx-small; color: #808080;"><span style="color: #0000ff;">strconcat macroDIR '\TERATERM.INI'</span> ;; ■ INIファイル名</span></div><div><span style="font-size: xx-small; color: #808080;">paramINI = macroDIR&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ INIファイルの値</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ 表示するサーバ名の設定</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #0000ff;">strdim Server_NAME <span style="color: #ff0000;">5</span></span></div><div><span style="font-size: xx-small; color: #0000ff;">Server_NAME[0] = '<span style="color: #ff0000;">【ｻｰﾊﾞ名】</span>'</span></div><div><span style="font-size: xx-small; color: #0000ff;">Server_NAME[1] = '<span style="color: #ff0000;">【ｻｰﾊﾞ名】</span>'</span></div><div><span style="font-size: xx-small; color: #0000ff;">Server_NAME[2] = '<span style="color: #ff0000;">【ｻｰﾊﾞ名】</span>'</span></div><div><span style="font-size: xx-small; color: #0000ff;">Server_NAME[3] = '<span style="color: #ff0000;">【ｻｰﾊﾞ名】</span>'</span></div><div><span style="font-size: xx-small; color: #0000ff;"><span style="font-size: xx-small; color: #0000ff;">Server_NAME[4] = '<span style="font-size: xx-small; color: #ff0000;">【ｻｰﾊﾞ名】</span></span>'</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ 対象IPアドレスの設定</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #0000ff;">strdim Server_IPaddress <span style="color: #ff0000;">5</span></span></div><div><span style="font-size: xx-small; color: #0000ff;">Server_IPaddress[0] = '<span style="font-size: xx-small; color: #ff0000;">192.168.0.xx</span>'</span></div><div><span style="font-size: xx-small; color: #0000ff;">Server_IPaddress[1] = '<span style="color: #ff0000;">192.168.0.xx</span>'</span></div><div><span style="font-size: xx-small; color: #0000ff;">Server_IPaddress[2] = '<span style="color: #ff0000;">192.168.0.xx</span>'</span></div><div><span style="font-size: xx-small; color: #0000ff;">Server_IPaddress[3] = '<span style="color: #ff0000;">192.168.0.xx</span>'</span></div><div><span style="font-size: xx-small; color: #0000ff;">Server_IPaddress[4] = '<span style="color: #ff0000;">192.168.0.xx</span>'</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ 選択画面の表示</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><strong><span style="font-size: xx-small; color: #808080;"><span style="color: #ff0000;">listbox</span> <span style="color: #0000ff;">'『対象を選択してください』' '【サーバ名】' Server_NAME</span></span></strong></div><div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ 選択したresult値を取得</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;"><span style="color: #0000ff;">if result &gt;= 0 then</span></span></div><div><span style="font-size: xx-small; color: #0000ff;">&nbsp; &nbsp; paramIP = Server_IPaddress[result]</span></div><div><span style="font-size: xx-small; color: #0000ff;">&nbsp; &nbsp; LOG_File = Server_NAME[result]</span></div><div><span style="font-size: xx-small; color: #0000ff;">else</span></div><div><span style="font-size: xx-small; color: #0000ff;">&nbsp; &nbsp; end</span></div><div><span style="font-size: xx-small; color: #0000ff;">endif</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ SSH接続コマンド編集</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><strong><span style="font-size: xx-small; color: #808080;">LoginSSH = paramIP&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ IPアドレス</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH ':22 /ssh /2 /auth=' ;; ■ 認証方式オプション</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH paramAUTH&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ 認証方式の値</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH ' /user='&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ ユーザ名オプション</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH paramUSER&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ ユーザ名の値</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH ' /passwd='&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ パスワードオプション</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH paramPASS&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; ■ パスワードの値</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH ' /F='&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;; ■ INIファイルオプション</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LoginSSH paramINI&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;; ■ INIファイルの値</span></strong></div><div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ SSH接続ログイン</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">connect LoginSSH</span></div><div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ LOGファイルの設定</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><strong><span style="font-size: xx-small; color: #808080;">getdir LOG_Path</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LOG_Path '\LOG\'</span></strong></div><div><strong><span style="font-size: xx-small; color: #0000ff;">getdate LogDate '_%Y%m%d-%H%M%S.log'</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LOG_File LogDate</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">strconcat LOG_Path LOG_File</span></strong></div><div><strong><span style="font-size: xx-small; color: #808080;">logopen LOG_Path 1 1</span></strong></div><div></div><div><span style="font-size: xx-small; color: #808080;">;; messagebox LOG_Path 'デバッグ用メッセージ'</span></div><div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ タイトル設定</span></div><div><span style="font-size: xx-small; color: #808080;">;-----------------------------</span></div><div><strong><span style="font-size: xx-small; color: #808080;">settitle LOG_Path</span></strong><br />
<br />
</div></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="font-size: xx-small; color: #808080;">;■ プロンプト待ち＆コマンド</span></div><div><span style="font-size: xx-small; color: #808080;">;*****************************</span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">wait '$' '#'</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">sendln</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">sendln</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">send 'date ; uname -n ; id'</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">sendln</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">sendln</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">wait '$' '#'</span></strong></span></div><div><span style="color: #808080;"><strong><span style="font-size: xx-small;">sendln</span></strong></span></div>]]> 
    </content>
    <author>
            <name>Account</name>
        </author>
  </entry>
  <entry>
    <id>archives.blog-mmo.com://entry/187</id>
    <link rel="alternate" type="text/html" href="https://archives.blog-mmo.com/powershell/%E3%80%90powershell%E3%80%91%E9%96%A2%E6%95%B0%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88" />
    <published>2026-05-09T13:55:42+09:00</published> 
    <updated>2026-05-09T13:55:42+09:00</updated> 
    <category term="PowerShell" label="PowerShell" />
    <title>【PowerShell】関数オブジェクト</title>
    <content mode="escaped" type="text/html" xml:lang="utf-8"> 
      <![CDATA[<div><strong><span style="color: #808080; font-size: xx-small;">REM ▼▲▼▲▼▲▼▲▼▲▼▲▼</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">REM ▼スクリプトファイル名&nbsp;&nbsp;</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">REM ▲『WinMerge_Excel.bat』</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">REM ▲▼▲▼▲▼▲▼▲▼▲▼▲</span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">@echo off</span></div><div><span style="color: #808080; font-size: xx-small;">REM **************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # conhost切替</span></div><div><span style="color: #808080; font-size: xx-small;">REM **************************</span></div><div><strong><span style="color: #808080; font-size: xx-small;">if not "%1"=="am_admin" (</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; start conhost "%~f0" am_admin &amp; exit /b</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">)</span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">REM **************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # 画面サイズ設定</span></div><div><span style="color: #808080; font-size: xx-small;">REM # カラー設定</span></div><div><span style="color: #808080; font-size: xx-small;">REM # 文字コード設定</span></div><div><span style="color: #808080; font-size: xx-small;">REM **************************</span></div><div><strong><span style="color: #808080; font-size: xx-small;">mode con: cols=120 lines=16</span></strong></div><div><span style="color: #808080; font-size: xx-small;">color 0a</span></div><div><span style="color: #808080; font-size: xx-small;">chcp 932</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">timeout 1</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">REM **************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # PowerShell実行</span></div><div><span style="color: #808080; font-size: xx-small;">REM **************************</span></div><div><strong><span style="color: #808080; font-size: xx-small;">powershell -ExecutionPolicy RemoteSigned -File <span style="color: #0000ff; font-size: xx-small;">"%CD%\WinMerge_Excel.ps1"</span></span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">timeout 5</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">REM **************************</span></div><div><span style="color: #808080; font-size: xx-small;">REM # バッチ終了処理</span></div><div><span style="color: #808080; font-size: xx-small;">REM **************************</span></div><div><span style="color: #808080; font-size: xx-small;">color 17</span></div><div><span style="color: #808080; font-size: xx-small;">cls</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">echo .</span></div><div><span style="color: #808080; font-size: xx-small;">echo " ================= "</span></div><div><span style="color: #808080; font-size: xx-small;">echo " ====== END ====== "</span></div><div><span style="color: #808080; font-size: xx-small;">echo " ================= "</span></div><div><span style="color: #808080; font-size: xx-small;">echo .</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">timeout 3</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><strong><span style="color: #808080; font-size: xx-small;"># ▼▲▼▲▼▲▼▲▼▲▼▲▼</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;"># ▼スクリプトファイル名&nbsp;&nbsp;</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;"># ▲『WinMerge_Excel.ps1』</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;"># ▲▼▲▼▲▼▲▼▲▼▲▼▲</span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ .NET クラス読込</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><strong><span style="color: #808080; font-size: xx-small;">Add-Type -AssemblyName System.Windows.Forms</span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ 定数設定</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">#【年月日-時分秒】</span></div><div><strong><span style="color: #808080; font-size: xx-small;">$DayTime = Get-Date -Format <span style="color: #0000ff; font-size: xx-small;">"yyyyMMdd-HHmmss"</span></span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">#【WinMerge格納パス】</span></div><div><span style="color: #808080; font-size: xx-small;"># ※ 環境に合わせて以下のパスを設定</span></div><div><strong><span style="color: #808080; font-size: xx-small;">$winMerge = <span style="color: #0000ff;">"C:\Program Files\WinMerge\WinMergeU.exe"</span></span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">#【ポップアップメッセージ】</span></div><div><span style="color: #808080; font-size: xx-small;">$P_MSG_1 = "★★★★★ 【WinMerge】比較元（左側）ファイルを選択 ★★★★★"</span></div><div><span style="color: #808080; font-size: xx-small;">$P_MSG_2 = "★★★★★ 【WinMerge】比較先（右側）ファイルを選択 ★★★★★"</span></div><div><span style="color: #808080; font-size: xx-small;">$P_MSG_3 = "★★★★★ 【WinMerge】出力先を確認ください ★★★★★"</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">#【出力メッセージ】</span></div><div><span style="color: #808080; font-size: xx-small;">$W_MSG_0 = " ================= "</span></div><div><span style="color: #808080; font-size: xx-small;">$W_MSG_1 = " ※※※ 【PowerShell実行 &rArr; WinMerge】 ※※※ "</span></div><div><span style="color: #808080; font-size: xx-small;">$W_MSG_2 = " ※※※ 比較元と比較先のファイルを確認ください ※※※ "</span></div><div><span style="color: #808080; font-size: xx-small;">$W_MSG_3 = " ====== END ====== "</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">#【msgbox オブジェクト生成】</span></div><div><strong><span style="color: #808080; font-size: xx-small;">$msgbox = New-Object -ComObject Wscript.Shell</span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">#【fileDialog オブジェクト生成】</span></div><div><strong><span style="color: #808080; font-size: xx-small;">$FileDialog = New-Object System.Windows.Forms.OpenFileDialog</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">$fileDialog.Title = <span style="color: #0000ff;">"【★★★★★ 対象ファイルを選択してください ★★★★★】"</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">$FileDialog.Filter = <span style="color: #0000ff;">"すべてのファイル (*.*)|*.*"</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">$fileDialog.ValidateNames = <span style="color: #0000ff;">$false</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">$fileDialog.CheckFileExists = <span style="color: #0000ff;">$false</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">$fileDialog.CheckPathExists = <span style="color: #0000ff;">$true</span></span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ 関数設定</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">#【ダイアログからパス取得】</span></div><div><span style="color: #ff0000;"><strong><span style="font-size: xx-small;">function Select_File {</span></strong></span></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; if ($FileDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; $filePath = $FileDialog.FileName</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; #-----------------------------</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; #【アクセスチェック】</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; if (Test-Path -LiteralPath $filePath) {</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">return $filePath</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; } else {</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; &nbsp; &nbsp; Write-Error <span style="color: #0000ff;">"【*** Path ERROR ***】 : $_"</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; &nbsp; &nbsp; exit</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; }</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; } else {</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; Write-Host <span style="color: #0000ff;">"選択無し（キャンセル）"</span> -ForegroundColor Yellow</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; exit</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; }</span></strong></div><div><span style="color: #ff0000;"><strong><span style="font-size: xx-small;">}</span></strong></span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ 処理開始メッセージ表示</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host " "</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "$W_MSG_1"</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host " "</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">Start-Sleep 1</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ 比較元（左側）を選択</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">$msgbox.popup("$P_MSG_1")</span></div><div><strong><span style="color: #808080; font-size: xx-small;">$PATH_L = <span style="color: #ff0000;">Select_File</span></span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "【WinMerge】比較元（左側）: $PATH_L"</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">Start-Sleep 1</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ 比較先（右側）を選択</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;">$msgbox.popup("$P_MSG_2")</span></div><div><strong><span style="color: #808080; font-size: xx-small;">$PATH_R = <span style="color: #ff0000;">Select_File</span></span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "【WinMerge】比較先（右側）: $PATH_R"</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ 確認メッセージ表示</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host " "</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "$W_MSG_2"</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host " "</span></div><div><span style="color: #808080; font-size: xx-small;">pause</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ 出力先パス設定</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;"># ## $OUTPUT_Path = [Environment]::GetFolderPath("Desktop")</span></div><div><span style="color: #808080; font-size: xx-small;"># ## $OUTPUT_Path = (Get-Location).Path</span></div><div><strong><span style="color: #808080; font-size: xx-small;">$OUTPUT_Path = $PSScriptRoot</span></strong></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">$msgbox.popup("$P_MSG_3")</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "**************************************"</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "【WinMerge】フォルダ名&nbsp; : $OUTPUT_Path"</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ HTMLパス取得（生成）</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><strong><span style="color: #808080; font-size: xx-small;">$HTML_File = <span style="color: #0000ff;">"$OUTPUT_Path\Diff_HTML_$DayTime.html"</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">Get-ChildItem | Select-Object Name, Length | ConvertTo-Html &gt; <span style="color: #0000ff;">$HTML_File</span></span></strong></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "【WinMerge】ＨＴＭＬ名&nbsp; : $HTML_File"</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ WinMerge 比較実行</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><strong><span style="color: #808080; font-size: xx-small;"><span style="color: #ff0000;">&amp;</span> <span style="color: #0000ff;">$winMerge</span> /r /noninteractive /or <span style="color: #0000ff;">"$HTML_File" "$PATH_L" "$PATH_R"</span></span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ WinMerge比較結果を保存する</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">#【EXCELファイル名の設定】</span></div><div><strong><span style="color: #808080; font-size: xx-small;">$EXCEL_File = <span style="color: #0000ff;">"$OUTPUT_Path\Diff_Excel_$DayTime.xlsx"</span></span></strong></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "【WinMerge】エクセル名&nbsp; : $EXCEL_File"</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "**************************************"</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host " "</span></div><div><span style="color: #808080; font-size: xx-small;">pause</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">#【EXCEL オブジェクト生成】</span></div><div><strong><span style="color: #808080; font-size: xx-small;">$excel = New-Object -ComObject Excel.Application</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">$excel.Visible = <span style="color: #0000ff;">$false</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">$excel.DisplayAlerts = <span style="color: #0000ff;">$false</span></span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">#【EXCEL ファイル保存処理】</span></div><div><strong><span style="color: #808080; font-size: xx-small;">try {</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; $workbook = $excel.Workbooks.Open(<span style="color: #0000ff;">$HTML_File</span>)</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; $fileFormat = <span style="color: #0000ff;">51</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; $workbook.SaveAs(<span style="color: #0000ff;">$EXCEL_File,$fileFormat</span>)</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; Write-Host " "</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; Write-Host "【*** Excel保存完了 ***】 $EXCEL_File" -ForegroundColor Green</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; Write-Host " "</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">}</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">catch {</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; Write-Host " "</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; Write-Error "【*** EXCEL ERROR ***】 : $_"</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; Write-Host " "</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">}</span></strong></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ オブジェクト解放処理</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #0000ff;"><strong><span style="font-size: xx-small;">finally {</span></strong></span></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; #-----------------------------</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; #【EXCEL オブジェクト解放】</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; if ($workbook) {&nbsp;</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; <span style="color: #0000ff;">$workbook.Close($false)</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; }</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; <span style="color: #0000ff;">$excel.Quit()</span></span></strong></div><div><span style="color: #0000ff;"><strong><span style="font-size: xx-small;">&nbsp; [System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null</span></strong></span></div><div><span style="color: #0000ff;"><strong><span style="font-size: xx-small;">&nbsp; Remove-Variable excel</span></strong></span></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp;</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; #-----------------------------</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; #【fileDialog オブジェクト解放】</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; <span style="color: #0000ff;">$fileDialog.Dispose()</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp;</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; #-----------------------------</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; #【msgbox オブジェクト解放】</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; <span style="color: #0000ff;">$msgbox = $null</span></span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; if ($null -ne $msgbox) {</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; [System.Runtime.InteropServices.Marshal]::ReleaseComObject($msgbox) | Out-Null</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; #-----------------------------</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; #【ガベージコレクション強制】</span></strong></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; &nbsp; <span style="color: #0000ff;">[System.GC]::Collect()</span></span></strong></div><div><span style="color: #0000ff;"><strong><span style="font-size: xx-small;">&nbsp; &nbsp; [System.GC]::WaitForPendingFinalizers()</span></strong></span></div><div><strong><span style="color: #808080; font-size: xx-small;">&nbsp; }</span></strong></div><div><span style="color: #0000ff;"><strong><span style="font-size: xx-small;">}</span></strong></span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">#******************************</span></div><div><span style="color: #808080; font-size: xx-small;"># ■ 処理終了メッセージ表示</span></div><div><span style="color: #808080; font-size: xx-small;">#-----------------------------</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host " "</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "$W_MSG_0"</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "$W_MSG_3"</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host "$W_MSG_0"</span></div><div><span style="color: #808080; font-size: xx-small;">Write-Host " "</span></div><div><span style="color: #808080; font-size: xx-small;">&nbsp;</span></div><div><span style="color: #808080; font-size: xx-small;">Start-Sleep 2</span></div>]]> 
    </content>
    <author>
            <name>Account</name>
        </author>
  </entry>
</feed>