강좌 / 팁

윈 도 우 설치된 기본프린터 확인 및 테스트페이지 인쇄 vbscript

2020.01.14 12:46

레마클로 조회:2542 추천:23

 

 

컴퓨터 수리업을 접은 지 5년 되어가네요.

업자분 들 필드에서 이용하실 수 있는 자료 들 틈나는 대로 올려 보겠습니다.

 

 

설치된 기본프린터 확인 및 테스트페이지 인쇄

윈도10 에서 저도 사용중입니다.

 

스크립트 시작

 

'--------------

If WScript.Arguments.length =0 Then

  Set objShell = CreateObject("Shell.Application")

  objShell.ShellExecute "wscript.exe", Chr(34) & _

  WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1

Else

'--------------

 

Dim objWMIService, colProcessList, objShell, objFSO, outFile

Set objShell = WScript.CreateObject("WScript.Shell")

Set objFSO = CreateObject("Scripting.FileSystemObject") 

curDir = objfso.GetParentFolderName(WScript.ScriptFullName) 

Set outFile = objFSO.CreateTextFile(curDir & "\DefPRNprint.cmd", True)

 

outFile.WriteLine "@echo off"

outFile.WriteLine "pushd ""%~dp0"""

outFile.WriteLine "setlocal"

outFile.WriteLine "for /f ""tokens=2*"" %%a in ('reg query ""HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows"" /v Device') do (set DefPRN1=%%b)"

outFile.WriteLine "for /f ""tokens=1 delims=,"" %%a in (""%DefPRN1%"") do set DefPRN=%%a"

outFile.WriteLine "start RUNDLL32 PRINTUI.DLL,PrintUIEntry /k /n ""%DefPRN%"""

outFile.WriteLine "endlocal"

outFile.Close

 

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _

 ("Select * from Win32_Printer Where Default = TRUE")

 

For Each objPrinter in colInstalledPrinters

x=msgbox("★ 기본 프린터 : " & objPrinter.Name & "  ★" +vbCrLf+ "" +vbCrLf+ "            [  테스트 페이지를 인쇄할까요?  ]", 4, "기본 프린터 확인 & 테스트 페이지 인쇄")

Next

If x = VbYes Then

objShell.Run chr(34) & curDir & "\DefPRNprint.cmd" & Chr(34), 0, True

objFSO.DeleteFile(curDir & "\DefPRNprint.cmd")

Else

objFSO.DeleteFile(curDir & "\DefPRNprint.cmd")

Wscript.Quit

End If

End If

 

스크립트 끝

 

지후아빠님이 수정해주신 깔끔버전입니다.  

 

Dim objWMIService, colProcessList, objShell, objFSO, outFile

Set objShell = WScript.CreateObject("WScript.Shell")

Set objFSO = CreateObject("Scripting.FileSystemObject") 

curDir = objfso.GetParentFolderName(WScript.ScriptFullName) 

Set outFile = objFSO.CreateTextFile(curDir & "\DefPRNprint.cmd", True)

 

outFile.WriteLine "@echo off"

outFile.WriteLine "pushd ""%~dp0"""

outFile.WriteLine "setlocal"

outFile.WriteLine "for /f ""tokens=2*"" %%a in ('reg query ""HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows"" /v Device') do (set DefPRN1=%%b)"

outFile.WriteLine "for /f ""tokens=1 delims=,"" %%a in (""%DefPRN1%"") do set DefPRN=%%a"

outFile.WriteLine "start RUNDLL32 PRINTUI.DLL,PrintUIEntry /k /n ""%DefPRN%"""

outFile.WriteLine "endlocal"

outFile.Close

 

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'UTIL.exe'")

For Each objProcess in colProcessList

 objProcess.Terminate()

Next

 

Set colPrinters =  objWMIService.ExecQuery("Select * from Win32_Printer Where Default = TRUE")

For Each objPrinter in colPrinters

x = msgbox("★ 기본 프린터 : " & objPrinter.Name & "  ★" & vbCrLf & vbCrLf & _

"            [  테스트 페이지를 인쇄할까요?  ]", 4, "기본 프린터 확인 & 테스트 페이지 인쇄")

If x = VbYes Then objShell.Run chr(34) & curDir & "\DefPRNprint.cmd" & Chr(34), 0, True

Next

 

 

objFSO.DeleteFile(curDir & "\DefPRNprint.cmd")

 
번호 제목 글쓴이 조회 추천 등록일
[공지] 강좌 작성간 참고해주세요 gooddew - - -
4389 윈 도 우| [실사] Windows 10/11 업데이트 통합본 ISO 만들기 [16] 무월 3149 31 11-12
4388 소프트웨어| 윈포 쪽지 전달 반자동화 AHK 매크로(배포중지) [39] 지후빠 1685 31 08-23
4387 윈 도 우| (수정) WIM 우클릭 부팅 관련 메뉴 4번째 [21] 지후빠 2764 31 04-24
4386 윈 도 우| Windows OEM Key & TPM 2.0 [17] kernel 5754 31 08-21
4385 윈 도 우| PE 업데이트 스크립트 V1.30 [12] 히이이잌 2573 31 12-20
4384 윈 도 우| 나만의 복구 솔루션 만들기 -1부- (UEFI) [36] gooddew 7849 31 06-06
4383 소프트웨어| ESD 다중 이미지 단일 WIM 이미지 추출 방법! [12] 무월 1080 30 08-09
4382 윈 도 우| [실사] 만능WIM 응답파일(Unattend.xml) 교체 [33] 무월 2866 30 08-21
4381 윈 도 우| 리소스 잡아먹는 Edge 설정 한방에 하기 [39] zerojiddu 7693 30 09-06
4380 소프트웨어| Rufus를 사용하여 Windows 11 부팅 가능한 USB를 만드는 방법 [24] VᴇɴᴜꜱGɪ 4133 30 08-16
4379 윈 도 우| IP 주소 변경 배치(DSN/WINS) [20] 무월 3542 30 12-28
4378 윈 도 우| 디펜더 켜기/끄기 (요청) [19] 슈머슈마 7525 30 12-28
4377 소프트웨어| 구글드라이브 다운로드 배치파일과 오토핫키 완성 [23] 지후빠 2137 30 08-29
4376 윈 도 우| 북마크 백업 복구 배치파일 [17] 센돔타오르 2247 30 08-03
4375 윈 도 우| Win PE에서 윈도우 UEFI설치를 합니다. [18] 하늘은높고 5107 30 04-05
4374 소프트웨어| PE 유틸 업데이트 하기 - RSImageX 사용 [17] suk 6457 30 10-20
4373 윈 도 우| Windows 10 새로운 시작 메뉴 정리와 reg 테스트 [14] suk 5181 30 08-07
4372 윈 도 우| VMware 윈도우10 RS4 Sysprep 통합윈도우 만들기 [33] 아차카차 7823 30 06-01
4371 소프트웨어| VMware workstation 사용법(본문 수정-2) [76] 고양이2 14926 30 11-14
4370 윈 도 우| 윈도우11&10 앱 제거 무인설치 [16] 무월 1202 29 03-22
XE1.11.6 Layout1.4.8