unote 書けば書くほどに

20230122

       public Form1()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Excel.Application excelApp = new Excel.Application();
            Excel.Workbooks excelBooks = excelApp.Workbooks;
            Excel.Workbook excelBook = excelBooks.Add();
            Excel.Worksheet sheet = excelApp.Worksheets["sheet1"];

            try
            {
                Console.WriteLine("開始...");
                int i = 1;

                string strInput = textBox1.Text;
                string path = strInput;

                if (strInput == "")
                {
                    MessageBox.Show("フォルダパスを入力してください","確認");
                }
                else
                {
                    // ディレクトリ直下のすべてのディレクトリ一覧を取得する
                    string[] dirs = Directory.GetDirectories(path);
                    foreach (string s in dirs)
                    {
                        Console.WriteLine(s);
                        listBox1.Items.Add(s);
                        string repstr = s.Replace("C:", "D:");//ドライブ名を置き換え

                        excelApp.Visible = true;//Excelを起動
                        sheet.Cells[i, 1] = repstr;
                        sheet.Cells[i, 2] = "=HYPERLINK(A" + i + ")";
                        i++;
                    }
                    Console.WriteLine("完了");
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                //excelApp.Quit();
                //System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet);
                //System.Runtime.InteropServices.Marshal.ReleaseComObject(excelBook);
                //System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Excel.Application excelApp = new Excel.Application();
            Excel.Workbooks excelBooks = excelApp.Workbooks;
            Excel.Workbook excelBook = excelBooks.Add();
            Excel.Worksheet sheet = excelApp.Worksheets["sheet1"];

            Console.WriteLine("開始...");
            int i = 1;

            string strInput = textBox1.Text;
            string path = strInput;

            // ディレクトリ直下のすべてのディレクトリ一覧を取得する
            string[] dirs = Directory.GetDirectories(path);
            foreach (string s in dirs)
            {
                Console.WriteLine(s);
                listBox1.Items.Add(s);
                excelApp.Visible = true;
                sheet.Cells[i, 1] = s;
                sheet.Cells[i, 2] = "=HYPERLINK(A" + i + ")";
                i++;
            }

            //ファイルを出力して、リンクを作成
            string[] files = Directory.GetFiles(strInput, "*");
            Console.WriteLine(files.Length);

            foreach (string str in files)
            {
                Console.WriteLine(str);

                excelApp.Visible = true;
                sheet.Cells[i, 1] = str;
                sheet.Cells[i, 2] = "=HYPERLINK(A" + i + ")";
                i++;

            }

            Console.WriteLine("完了");
            }

        private void button3_Click(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            ProcessStartInfo psInfo = new ProcessStartInfo();
            psInfo.FileName = @"C:\wifi\echoSSID.bat"; // 実行するファイル
            psInfo.CreateNoWindow = false; // コンソール・ウィンドウを開かない
            psInfo.UseShellExecute = false; // シェル機能を使用しない
            Process.Start(psInfo);

            var ssidList = new List<string>()
            {
                @"C:\wifi\hello.bat",
                @"C:\wifi\echoSSID.bat"
                //@"C:\wifi\exportSSID.bat" 
            };

            foreach (var ssid in ssidList)
            {
                Console.WriteLine(ssid);// 赤 黄 青


            }

        }


@echo off

netsh wlan show profiles
set /p ssidname="SSIDを入力してください :"
echo SSID:%ssidname%
netsh wlan export profile name=%ssidname% folder=C:\wifi

pause

@echo off

for %%i in (aaa,bbb,ccc,ddd) do (
    echo %%i
    netsh wlan add profile filename=%%i%.xml > nul 2>&1
    netsh wlan set profileparameter name=%%i keymaterial=<パスワード> connectionmode=auto > nul 2>&1
)

pause