質問するログイン新規登録

質問編集履歴

1

最終的なコードを追記

2019/11/09 09:33

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -82,4 +82,28 @@
82
82
 
83
83
  環境は、Windows10 Pro 64bit です。
84
84
 
85
- よろしくお願いします。
85
+ よろしくお願いします。
86
+
87
+ ### まとめ(追記)
88
+ 最終的なコードです。
89
+ ```.bat
90
+ @echo off&title %~n0&setlocal enabledelayedexpansion&for /f "tokens=*" %%i in ('certutil -hashfile "%~f0"^|find /v":"') do (set app_hash=%%i)
91
+ set app_name=%~dp0%~n0[%app_hash%]&set src_path=!app_name!.cs
92
+ if not exist "%app_name%.exe" (del "%~dp0%~n0[*].*">nul 2>&1&type "%~f0"|more +5>"%src_path%"&for /f "tokens=*" %%i in ('where /r %windir%\Microsoft.NET csc.exe^|sort') do (set compiler_path=%%i)
93
+ "!compiler_path!" /nologo /out:"%app_name%.exe" "%src_path%")
94
+ "%app_name%.exe" %*&exit /b %errorlevel%
95
+
96
+ //! @file template.bat
97
+ //! @version 1.00r1
98
+
99
+ using System;
100
+
101
+ class Program
102
+ {
103
+ static void Main(string[] args)
104
+ {
105
+ Console.WriteLine("Hello C# !!");
106
+ Console.ReadKey();
107
+ }
108
+ }
109
+ ```