Skip to content

Instantly share code, notes, and snippets.

@themaximax
Last active October 11, 2024 07:54
Show Gist options
  • Save themaximax/fd2a7b16b75bec490abc280fab4201ce to your computer and use it in GitHub Desktop.
Save themaximax/fd2a7b16b75bec490abc280fab4201ce to your computer and use it in GitHub Desktop.
Файлы к заметке "печать на сетевой принтер без драйверов" #linux https://vk.com/@itmax-pechat-na-setevoi-printer-bez-draiverov
[Unit]
Description=Авто монтирование сетевой папки
[Automount]
Where=/mnt/print
TimeoutIdleSec=30
[Install]
WantedBy=graphical.target
[Unit]
Description=Монтирование сетевой папки
After=nss-lookup.target
[Mount]
Type=cifs
What=//goncharova-pc/share
Where=/mnt/share
Options=_netdev,iocharset=utf8,rw,file_mode=0777,dir_mode=0777,credentials=/etc/samba/smbcreds
TimeoutSec=10
[Install]
WantedBy=graphical.target
# указываем путь до сетевой папки печати
$pdir = 'C:\Share\Print'
if (!(Test-Path -Path $pdir)) {
New-Item -Path $pdir -ItemType Directory -ErrorAction Stop
}
Set-Location $pdir
while ($True) {
Get-ChildItem $pdir -Recurse -Filter "*.pdf" |
ForEach-Object {
# Write-Host "> $_" -NoNewline
Start-Process -FilePath $_ -Verb print -Wait
# Write-Host " - Готово"
Start-Sleep 2
Remove-Item $_
}
Start-Sleep 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment