강좌 / 팁

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

2020.01.14 12:46

레마클로 조회:2553 추천: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 - - -
4479 윈 도 우| PrincePE_V18.5 [164] %카리스마 204984 99 02-02
4478 윈 도 우| 윈도우7 Windows 정품 인증 기술 업데이트로 인증하기 [21] 얼룩강아지 111628 0 02-27
4477 윈 도 우| 비스타(VISTA) 인증 후 무한 리부팅 현상 해결법 [1] gooddew 98131 0 06-17
4476 윈 도 우| 바이오스 안에 OEM SLIC 가 내장되었는지 확인하는 방법 [5] gooddew 84995 0 06-17
4475 윈 도 우| UEFI-모드 부팅 [설치 USB] 만들기 [8] eunnano 77025 0 09-07
4474 A.I 사용법 무작정 따라하기 (스샷 첨부) - 마지막 수정 [67] PoLaRiS 74990 6 09-10
4473 하드웨어| 유튜브 버퍼링 완전해결2 (hosts파일 사용, DNS변경 x, SKB... [44] hsk 63915 6 05-06
4472 윈 도 우| 비스타/세븐 DVD-4cd 분할 가이드 v2 김간지 63412 0 01-21
4471 윈 도 우| Usb를 이용한 XP설치 [21] 고맙쥐 62277 11 10-23
4470 윈 도 우| 비스타의 숨겨진 부팅로고를 보자 [5] cdcsj 60484 0 05-26
4469 윈 도 우| 소소한팁..Windows 로그온 사진이 작을때.. 김간지 59253 0 07-12
4468 윈 도 우| God Mode 만들기 [5] 적광 55432 0 12-26
4467 기 타| Superfetch 기능 사용중단하기 [13] gooddew 55294 1 09-16
4466 윈 도 우| Win7_8 PE/수정/추가/바탕화면/교체하기 [13] 까꾸리 54308 17 05-18
4465 Windows 7 과 XP 프린터와 파일 서로 공유하기 [5] sp2 52848 3 08-22
4464 윈 도 우| 윈도우8 다국어 언어팩 설치 방법(영문 기준) [6] chkid 51182 5 11-11
4463 윈 도 우| 삼성 노트북의 복원솔루션 5 를 이용하여 SSD에 복원영역 ... [13] 울랄라백수 48974 4 06-17
4462 소프트웨어| USB키보드인채로 PLOP 사용하기 (USB 2.0 MODE + PE) [19] hazuki 48384 0 01-19
4461 윈 도 우| 만능고스트 사용후 hal.dll 오류로 부터 벗어나기 [2] cdcsj 47763 0 04-29
XE1.11.6 Layout1.4.8