【基本関数】 : baseFunction

  GetWshShell



Microsoft のリファレンスへのリンク

  
REM **********************************************************
REM WScript.Shell の取得
REM **********************************************************
Function GetWshShell( )

	if not IsObject( WshShell ) then
		Call GetObj( "WshShell", "WScript.Shell" )
	end if

End Function
  



  RunAsync



  
REM **********************************************************
REM 非同期実行
REM **********************************************************
Function RunAsync( strCommand )

	GetWshShell
	Call WshShell.Run( strCommand )

End Function
  



  RunSync、RunSync2

実行プログラムのパスが、空白を含んでいる場合は Dd を使用して下さい

  
REM **********************************************************
REM 同期実行( 必要ならコマンドプロンプトを開く )
REM **********************************************************
Function RunSync( strCommand )

	GetWshShell
	Call WshShell.Run( strCommand, , True )

End Function

REM **********************************************************
REM 同期実行( コマンドプロンプトを開かない )
REM **********************************************************
Function RunSync2( strCommand )

	GetWshShell
	Call WshShell.Run( strCommand, 0, True )

End Function
  



  RunBat、RunBatParam

GetInline で取得したテキストをバッチファイルとして実行します

  
REM **********************************************************
REM バッチファイル 実行
REM **********************************************************
Function RunBat( strName )

	Dim strPath,strCommand

	strPath = Tempdir & "\" & strName & ".bat"
	Call PutTextFile( strPath, GetInline(strName) )
	strCommand = "cmd.exe /c " & Dd( strPath )
	RunSync( strCommand )

End Function

REM **********************************************************
REM バッチファイル パラメータ(置き換え)実行
REM **********************************************************
Function RunBatParam( strName, bPause, strParamList )

	Dim strPath,strCommand,aParam,str,I

	aParam = Split(strParamList,",")

	strPath = Tempdir & "\" & strName & ".bat"
	str = GetInline(strName)
	For I = 0 to Ubound( aParam ) step 2
		str = Replace( str, aParam(I), aParam(I+1) )
	Next
	Call PutTextFile( strPath, str )
	strCommand = "cmd.exe /c " & Dd( strPath )
	RunSync( strCommand )

End Function
  



  RunPhp、RunPhpParam

  
REM **********************************************************
REM PHP 実行
REM **********************************************************
Function RunPhp( strName, bPause )

	Dim strPath,strCommand

	strPath = Tempdir & "\" & strName & ".php"
	Call PutTextFile( strPath, GetInline(strName) )
	if bPause then
		strCommand = "cmd.exe /c php.exe " & Dd( strPath ) & " & pause"
	else
		strCommand = "php.exe " & Dd( strPath )
	end if
	RunSync( strCommand )

End Function

REM **********************************************************
REM PHP パラメータ(置き換え)実行
REM **********************************************************
Function RunPhpParam( strName, bPause, strParamList )

	Dim strPath,strCommand,aParam,str,I

	aParam = Split(strParamList,",")

	strPath = Tempdir & "\" & strName & ".php"
	str = GetInline(strName)
	For I = 0 to Ubound( aParam ) step 2
		str = Replace( str, aParam(I), aParam(I+1) )
	Next
	Call PutTextFile( strPath, str )
	if bPause then
		strCommand = "cmd.exe /c php.exe " & Dd( strPath ) & " & pause"
	else
		strCommand = "php.exe " & Dd( strPath )
	end if
	RunSync( strCommand )

End Function
  



  CopyNewfile、CopyAllfile

  
REM **********************************************************
REM XCOPY で新しいファイルのみコピー
REM **********************************************************
Function CopyNewfile(SourceDir,DestinationDir)

	Dim nRet

	GetWshShell

	ExecCommand = "xcopy.exe """ & SourceDir & """ """ & DestinationDir & """ /D /E /C /S /Y"

	RunSync( ExecCommand )

End function

REM **********************************************************
REM XCOPY で全てのファイルコピー
REM **********************************************************
Function CopyAllfile(SourceDir,DestinationDir)

	Dim nRet

	GetWshShell

	ExecCommand = "xcopy.exe """ & SourceDir & """ """ & DestinationDir & """ /E /C /S /Y"

	RunSync( ExecCommand )

End function
  



  GetWshNetwork、GetDic、GetShell

  
REM **********************************************************
REM WScript.Network の取得
REM **********************************************************
Function GetWshNetwork( )

	if not IsObject( WshNetwork ) then
		Call GetObj( "WshNetwork", "WScript.Network" )
	end if

End Function

REM **********************************************************
REM ディクショナリオブジェクトの取得
REM **********************************************************
Function GetDic( )

	if not IsObject( Dic ) then
		Call GetObj( "Dic", "Scripting.Dictionary" )
	end if

End Function

REM **********************************************************
REM Shell オブジェクトの取得
REM **********************************************************
Function GetShell( )

	if not IsObject( Shell ) then
		Call GetObj( "Shell", "Shell.Application" )
	end if

End Function
  



  SelectDir

  
REM **********************************************************
REM フォルダ選択
REM **********************************************************
Function SelectDir( strTitle )

	if ScriptType <> 3 then
	else
		Exit Function
	end if

	GetShell

	Dim obj

	Set obj = Shell.BrowseForFolder( 0, strTitle, 11, 0 )
	if obj is nothing then
		SelectDir = ""
		Exit Function
	end if
	if not obj.Self.IsFileSystem then
		ErrorMessage = "ファイルシステムではありません"
		SelectDir = ""
		Exit Function
	end if

	SelectDir = obj.Self.Path

End Function

Function SelectDirAndFile( strTitle )

	if ScriptType <> 3 then
	else
		Exit Function
	end if

	GetShell

	Dim obj

	on error resume next
	Set obj = Shell.BrowseForFolder( 0, strTitle, 11 + &h4000, 0 )
	if Err.Number <> 0 then
		ErrorMessage = "ファイルが選択されました"
		SelectDirAndFile = ""
		Exit Function
	end if
	on error goto 0
	if obj is nothing then
		SelectDirAndFile = ""
		Exit Function
	end if
	if not obj.Self.IsFileSystem then
		ErrorMessage = "ファイルシステムではありません"
		SelectDirAndFile = ""
		Exit Function
	end if

	SelectDirAndFile = obj.Self.Path

End Function
  



  OpenDir

  
REM **********************************************************
REM エクスプローラで開く
REM **********************************************************
Function OpenDir( strPath )

	strCommand = "explorer.exe  /e," & Dd(strPath)
	RunSync(strCommand)

End Function
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ