강좌 / 팁

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

2020.01.14 12:46

레마클로 조회:2550 추천: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 - - -
4378 윈 도 우| winpe에서 startis[all]back를 이용한 탐색기 색 변경 [14] sunshine 608 14 08-23
4377 윈 도 우| [2탄] install.wim 누적 업데이트 + 드라이버 통합 하기 (D... [9] 무월 1369 28 08-21
4376 윈 도 우| [1탄] install.wim 누적 업데이트 통합 하기 [26] 무월 1868 45 08-19
4375 모 바 일| AirPrint 설정 및 호환 프린터 목록 [1] asklee 745 3 08-18
4374 윈 도 우| Windows Defender 방화벽 인/아웃바운드 허용/차단 추가 [20] 무월 2070 35 08-17
4373 소프트웨어| 중국어 하드 코딩 한글화 강좌 [8] 줄리아니 1062 20 08-16
4372 소프트웨어| 중국어 프로그램 한글화 팁 [8] 줄리아니 1200 16 08-14
4371 소프트웨어| LaunchBar boot.wim 적용 방법 [12] 무월 1527 35 08-13
4370 소프트웨어| (추가3) 배치파일 추가기능 extd.exe 사용 팁 [7] 지후빠 945 24 08-13
4369 소프트웨어| 중국어 프로그램 한글화 팁 [11] 줄리아니 1382 20 08-10
4368 소프트웨어| ESD 다중 이미지 단일 WIM 이미지 추출 방법! [12] 무월 1084 30 08-09
4367 소프트웨어| 크롬 하단 다운로드창 활성화 [11] 무월 2784 46 08-03
4366 소프트웨어| wim boot 관련 배치 파일 몇 가지 팁 [19] 지후빠 1454 29 08-03
4365 기 타| 포토샵 많이 좋아졌네요!! [3] 집에서뒹굴 2743 5 08-02
4364 모 바 일| [Tip] 인천공항 스마트패스 - 얼굴 인식으로 출국장 통과 앱 [5] asklee 1760 9 07-28
4363 소프트웨어| 다음 팟플레이어 광고[팝업] 차단 [12] 무월 3113 48 07-26
4362 윈 도 우| winpe 시작 화면 Shutdown 메뉴 수정 [10] sunshine 854 18 07-25
4361 소프트웨어| winpe 시스템 계정에서 Edge 상위버전 적용 [8] sunshine 566 15 07-24
4360 소프트웨어| Total Commander 주요 단축키 설명 [3] VᴇɴᴜꜱGɪ 1002 11 07-23
4359 윈 도 우| 없이는 살 수 없는 Windows 바로 가기 키 11개 [5] VᴇɴᴜꜱGɪ 2954 31 07-18
XE1.11.6 Layout1.4.8