Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8088

Профиль | Отправить PM | Цитировать


Ну, например, так:
Скрытый текст
Код: Выделить весь код
Option Explicit

Const strPath2Programm1 = "c:\Windows\System32\notepad.exe"
Const strPath2Programm2 = "c:\Windows\System32\calc.exe"

Const strPath2Folder    = "%Temp%\Some folder"

Const intWindowStyle    = 1 ' Activates and displays a window. 
                            ' If the window is minimized or maximized, 
                            ' the system restores it to its original size 
                            ' and position. An application should specify 
                            ' this flag when displaying the window 
                            ' for the first time.


Dim arrArguments()
Dim strArgument

Dim i

Dim objWshShell
Dim strPath2WorkFolder


If WScript.Arguments.Count > 0 Then
	ReDim arrArguments(WScript.Arguments.Count - 1)
	
	For i = 0 To WScript.Arguments.Count - 1
		WScript.Echo "[" & WScript.Arguments.Item(i) & "]"
		arrArguments(i) = WScript.Arguments.Item(i)
	Next
	
	Set objWshShell = WScript.CreateObject("WScript.Shell")
	
	With WScript.CreateObject("Scripting.FileSystemObject")
		If Not .FileExists(strPath2Programm1) Then
			WScript.Echo "Can't find programm file [" & strPath2Programm1 & "]."
			WScript.Quit 2
		End If
		
		If Not .FileExists(strPath2Programm2) Then
			WScript.Echo "Can't find programm file [" & strPath2Programm2 & "]."
			WScript.Quit 3
		End If
		
		For Each strArgument In arrArguments
			If Not .FileExists(strArgument) Then
				WScript.Echo "Can't find source file [" & strArgument & "]."
				WScript.Quit 4
			End If
		Next
		
		strPath2WorkFolder = objWshShell.ExpandEnvironmentStrings(strPath2Folder)
		
		If Not .FolderExists(strPath2WorkFolder) Then
			.CreateFolder strPath2WorkFolder
		End If
		
		objWshShell.Run """" & strPath2Programm1 & """ /WorkFolderParameter """ & strPath2WorkFolder & """ """ & Join(arrArguments, "|") & """", intWindowStyle, True
		objWshShell.Run """" & strPath2Programm2 & """ /WorkFolderParameter """ & strPath2WorkFolder & """ """ & Join(arrArguments, """ """) & """", intWindowStyle, True
		
		If .FolderExists(strPath2WorkFolder) Then
			.DeleteFolder strPath2WorkFolder, True
		End If
	End With
	
	Set objWshShell = Nothing
Else
	WScript.Echo "Usage: cscript.exe //nologo """ & WScript.ScriptName & """ <Source file1> [<Source file2> [...<Source fileN>]]"
	WScript.Quit 1
End If

WScript.Quit 0
Это сообщение посчитали полезным следующие участники:

Отправлено: 11:02, 02-08-2019 | #16