강좌 / 팁

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

2020.01.14 12:46

레마클로 조회:2554 추천: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 - - -
4403 서버 / IT| Linux Mint 20.3 에서 Linux Mint 21로 업그레이드 [2] VᴇɴᴜꜱGɪ 844 7 08-09
4402 윈 도 우| (수정) Extd 한글 설명서 [명령_문법 부분에 대하여 자세한... [4] 슈머슈마 846 6 02-21
4401 서버 / IT| WSL 2에 Kali Linux의 Win-KeX 데스크탑을 설치하는 방법 [1] VenusGirl 850 7 08-25
4400 하드웨어| [팁] 아이패드에서 마우스 휠 스크롤 방향 바꾸기 [1] asklee 856 1 06-01
4399 윈 도 우| winpe 시작 화면 Shutdown 메뉴 수정 [10] sunshine 860 18 07-25
4398 윈 도 우| PE에서 윈도우 폰트 사용하기 [5] PC_Clinic 861 17 03-08
4397 윈 도 우| 파일 및 폴더 경로 복사 컨텍스트 메뉴 [3] 슈머슈마 865 8 02-23
4396 소프트웨어| AIMP에서 라디오 스트림(방송)을 녹음하는 법 [1] VᴇɴᴜꜱGɪ 869 11 03-03
4395 기 타| [오토핫키 v1] 경로, 이름 ,드라이브명 등등 추출 함수 [2] 청락은복 869 8 03-06
4394 소프트웨어| [포토샵] 이미지 패턴 합성 [11] 무월 875 9 04-08
4393 기 타| 마우스 우측메뉴에 밀어서 윈도우 종료 추가하기 (영상) [6] 코요88 876 2 08-12
4392 윈 도 우| 작업스케쥴러를 이용하여 UAC 우회하기 [11] 지후빠 888 10 03-09
4391 기 타| 레마클로님 wifi on/off 스크립트 (수정) pnputil 추가 [10] 슈머슈마 889 7 06-20
4390 윈 도 우| 배치파일로 윈도 설정과 관계없이 일정한 날짜 얻기 [6] 히이이잌 890 12 02-16
4389 소프트웨어| PDF-XChange Editor 기본글꼴 바꾸기 [1] 코리아선비 894 3 09-25
4388 윈 도 우| 최신 EEA 호환 업데이트에서 Windows 11에서 Microsoft Edg... [1] VᴇɴᴜꜱGɪ 894 3 11-20
4387 소프트웨어| nircmd.exe 다운 받아 windir에 복사하기 ps1 ahk [19] 지후빠 895 6 01-05
4386 소프트웨어| [포토샵] 다중 개체 선택 지우기 액션 [4] 무월 898 13 04-03
4385 윈 도 우| [실사] 윈도우 7 32비트 VHD 설치 방법! [11] 무월 898 19 08-23
4384 기 타| PE StartIsBack 설정 [2] bangul 901 7 05-22
XE1.11.6 Layout1.4.8