SQLの窓 イラストAC フリー素材

2014年12月25日

画面いっぱいに開く cmdex.exe

▼ VB.net ビルド用コマンドプロンプトセット


Imports System
Imports System.Diagnostics

Module MyModule

' ******************
' * 実行
' ******************
Sub Main(ByVal CmdArgs() As String)

	Dim startInfo As New ProcessStartInfo("cmd.exe")
	startInfo.WindowStyle = ProcessWindowStyle.Maximized

	Dim w As Integer = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
	Dim cols As String = ""

	if w >= 1024 then
		cols = "120"
	end if
	if w >= 1152 then
		cols = "135"
	end if
	if w >= 1280 then
		cols = "150"
	end if

	Dim strArg As String = "/k mode con: cols=" & cols
	Dim idx As Integer = 0

	if CmdArgs.GetUpperBound(0) <> -1 then
		strArg &= " & "
		For idx = 0 to CmdArgs.GetUpperBound(0)
			strArg &= " " & CmdArgs(idx)
		Next
	end if
	startInfo.Arguments = strArg

	Process.Start(startInfo)

End Sub

End Module

ビルドしたものを使うのが嫌な人は、フレームワークがインストールされておれば、簡単にビルドできます。

__buildPath.txt
; Framework 4.0
%windir%\Microsoft.NET\Framework\v4.0.30319

; Framework 2.0
%windir%\Microsoft.NET\Framework\v2.0.50727
;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin

; 行先頭にセミコロンはコメントです。
; 記述されて有効なパスは全て読み込まれます
; なにも無い行は無視します


VBC_BUILD.wsf
<JOB>
<RESOURCE id="commandList">
<![CDATA[
mode con: cols=120
set PATH=$BIN;%PATH%
prompt vb.net$G
title Microsoft Framework アプリケーションのビルド
]]>
</RESOURCE>

<OBJECT id="WshShell" progid="WScript.Shell" />
<OBJECT id="Fso" progid="Scripting.FileSystemObject" />

<SCRIPT language=VBScript>
' ***********************************************
' 処理開始( コマンドラインからビルドする為のスクリプトです )
' ***********************************************

strPath = WScript.ScriptFullName
Set obj = Fso.GetFile( strPath )
Set obj = obj.ParentFolder
WshShell.CurrentDirectory = obj.Path

Set objHandle = Fso.OpenTextFile( obj.Path & "\__buildPath.txt", 1 )
Do While not objHandle.AtEndOfStream
	sLine = objHandle.ReadLine
	if Left( sLine, 1 ) <> ";" and sLine <> "" then
		if sPath <> "" then
			sPath = sPath & ";"
		end if
		sPath = sPath & sLine
	end if
Loop
objHandle.Close

aData = Split( GetInline( "commandList" ), vbCrLf )
strCommand = "cmd.exe /k " & aData(0)
For I = 1 to Ubound( aData )
	if instr( aData(I), "$BIN" ) > 0 then
		aData(I) = Replace( aData(I), "$BIN", sPath )
	end if
	strCommand = strCommand & "&" & aData(I)
Next
Call WshShell.Run( strCommand, 3 )

' ***********************************************
' 関数
' ***********************************************
Function GetInline( strName )

	GetInline = RegTrim( getResource( strName ) ) & vbCrLf

End Function
Function RegTrim( strValue )

	Dim regEx, str

	Set regEx = New RegExp
	regEx.IgnoreCase = True
	regEx.Pattern = "^[ \s]+"
	str = regEx.Replace( strValue, "" )
	regEx.Pattern = "[ \s]+$"
	RegTrim = regEx.Replace( str, "" )

End Function
</SCRIPT>
</JOB>


関連する記事


タグ:VB.NET
【VB.netの最新記事】
posted by at 2014-12-25 02:30 | VB.net | このブログの読者になる | 更新情報をチェックする