강좌 / 팁

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

2020.01.14 12:46

레마클로 조회:2558 추천: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 - - -
1976 윈 도 우| PrincePE_V18.5 [164] %카리스마 204986 99 02-02
1975 윈 도 우| 윈도우7 Windows 정품 인증 기술 업데이트로 인증하기 [21] 얼룩강아지 111629 0 02-27
1974 윈 도 우| 비스타(VISTA) 인증 후 무한 리부팅 현상 해결법 [1] gooddew 98131 0 06-17
1973 윈 도 우| 바이오스 안에 OEM SLIC 가 내장되었는지 확인하는 방법 [5] gooddew 84995 0 06-17
1972 윈 도 우| UEFI-모드 부팅 [설치 USB] 만들기 [8] eunnano 77031 0 09-07
1971 윈 도 우| 비스타/세븐 DVD-4cd 분할 가이드 v2 김간지 63413 0 01-21
1970 윈 도 우| Usb를 이용한 XP설치 [21] 고맙쥐 62282 11 10-23
1969 윈 도 우| 비스타의 숨겨진 부팅로고를 보자 [5] cdcsj 60484 0 05-26
1968 윈 도 우| 소소한팁..Windows 로그온 사진이 작을때.. 김간지 59255 0 07-12
1967 윈 도 우| God Mode 만들기 [5] 적광 55432 0 12-26
1966 윈 도 우| Win7_8 PE/수정/추가/바탕화면/교체하기 [13] 까꾸리 54352 17 05-18
1965 윈 도 우| 윈도우8 다국어 언어팩 설치 방법(영문 기준) [7] chkid 51184 5 11-11
1964 윈 도 우| 삼성 노트북의 복원솔루션 5 를 이용하여 SSD에 복원영역 ... [13] 울랄라백수 48974 4 06-17
1963 윈 도 우| 만능고스트 사용후 hal.dll 오류로 부터 벗어나기 [2] cdcsj 47764 0 04-29
1962 윈 도 우| 3. MS 인증 절차 - KMS 인증 [2] 공피 46642 0 02-14
1961 윈 도 우| 작업관리자에서 프로세스종료가 안될시에는? [6] 철부지영수 44483 0 12-27
1960 윈 도 우| USB로 XP 설치하기(AHCI 지원, USB CD 영역 불필요) [35] 해밀 44470 16 05-04
1959 윈 도 우| 탐색기에서 라이브러리 제거해도 작동하는 슬라이드쇼 가젯??? [1] Mir 44268 0 03-19
1958 윈 도 우| 해적인증 사용하시는 분들은 8.1 업그레이드 하시면 안됩니다. [17] 카리스마조 43328 0 10-18
1957 윈 도 우| 갓 모드(God Mode) [6] PoLaRiS 41890 0 03-21
XE1.11.6 Layout1.4.8