aloosha@vk
14-08-2023, 05:31
Здравствуйте, мне необходимо сделать, чтобы скрипт отправлял новый файл которые появляется в папке в другую папку и оттуда уже файл уходил на печать на принтер по умолчанию. Желательно просто скрипт который можно поместить в блокнот. Кто может помочь?
DJ Mogarych
14-08-2023, 08:50
Очень неконкретно сформулировано.
отправлял новый файл которые появляется в папке в другую папку »
Отправлял - это копировал или переносил?
Что значит "новый файл"? По каким критериям его считать новым?
В этой папке уже есть файлы или она пустая?
Почему сразу не печатать из исходной папки до "отправки"?
megaloman
14-08-2023, 16:19
BoxIn = "D:\CMD_Forum\Где файл"
Mask = "*.jp*g"
BoxOut = "Z:\Box_Out"
Interval = "2" 'Интервал опроса секунд
Set Sll = CreateObject("Shell.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSll = CreateObject("WScript.Shell")
If MsgBox("Начать мониторинг?", 33) = 2 Then WScript.Quit
L = PrintPaint(FSO, Sll, WSll, BoxIn, BoxOut, Mask)
With FSO
Drive = .GetDriveName(BoxIn)
Folder = Replace(Mid(BoxIn, 3), "\", "\\") + "\\"
End With
Set WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Query = "Select * From __InstanceOperationEvent Within " + Interval + " Where Targetinstance Isa 'CIM_DataFile' And TargetInstance.Drive='" + Drive + "' And TargetInstance.Path='" + Folder + "'"
Set Events = WMI.ExecNotificationQuery(Query)
Do
Set Evnt = Events.NextEvent()
Set Target = Evnt.TargetInstance
If Evnt.Path_.Class = "__InstanceCreationEvent" Then
L = PrintPaint(FSO, Sll, WSll, BoxIn, BoxOut, Mask)
End If
'''''''' If L Then If MsgBox("Продолжить мониторинг?", 33) = 2 Then WScript.Quit
Loop
'End Sub
Function PrintPaint(FSO, Sll, WSll, BoxIn, BoxOut, Mask)
PrintPaint = False
Set Box = Sll.Namespace(BoxIn)
Set BoxFile = Box.Items()
BoxFile.Filter 64 + 128, Mask
With FSO
For Each File In BoxFile
PrintPaint = True
If .FileExists(BoxOut + "\" + File) Then .DeleteFile BoxOut + "\" + File, True
.MoveFile BoxIn + "\" + File, BoxOut + "\" + File
WSll.Run "MsPaint /pt " + BoxOut + "\" + File, 1, False
Next
End With
End Function
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.