강좌 / 팁

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

2020.01.14 12:46

레마클로 조회:2551 추천: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 소프트웨어| pureBasic - WIM 정보 v0993 - 내부 파일 추가 삭제 내보내... [40] 입니다 8567 160 12-22
4478 소프트웨어| 한글2024 로고 교체 / 자동 설치 옵션 [54] 무월 13087 107 11-25
4477 소프트웨어| [추가기능1.1]엑셀 셀의 행-열 Auto-Highlight 하는 방법들 [77] 지후빠 2805 103 11-10
4476 윈 도 우| PrincePE_V18.5 [164] %카리스마 204983 99 02-02
4475 윈 도 우| PE 한글화 프로그램 (v1.0) [106] ㄱㅇㄱㄱㅁ 27982 89 06-25
4474 윈 도 우| 윈도우 10 설치, 최적화 및 기타 팁 100개 정리 [56] 컴알못러 27693 79 01-26
4473 윈 도 우| PrincePE_V20 [52] %카리스마 2835 72 03-05
4472 윈 도 우| 배치파일을 이용해서 윈도우 자동 설치하기 [22] gooddew 4943 70 10-16
4471 윈 도 우| Windows 10 Ultimate (DREAM HS) [58] @카리스마 7352 70 08-14
4470 소프트웨어| iVentoy 만능윈도우(WIM) 자동 설치 [20] 무월 4242 66 07-08
4469 윈 도 우| PrincePE_V19 [53] %카리스마 5096 65 02-15
4468 윈 도 우| 윈도우 장치 드라이버 추출(백업) 명령어 [25] 컨피그 2677 64 02-23
4467 윈 도 우| 윈도우10 만능이미지 제작 메뉴얼 [43] 질주민군 5582 64 11-19
4466 소프트웨어| 트루이미지(Acronis True Image) 추가본②(본문 수정) [91] 고양이2 9118 62 11-26
4465 윈 도 우| 무인응답파일(autounattend.xml) 쉽게 만들기 [30] 네오이즘 3826 60 12-31
4464 서버 / IT| 손쉽게 멀티부팅용 USB 만들기. (내용추가) [50] 디폴트 7402 60 05-31
4463 윈 도 우| WindowsXPE147-1빌더/나만의 PE를 만들자 시즌2 ?? 1탄 (... [49] update 지연서연아 1435 59 04-16
4462 윈 도 우| PrincePE_V22 [53] %카리스마 6600 59 03-06
4461 소프트웨어| ▣▣▣▣▣[ Ventoy 고급 응용편 자료 정리 ]▣▣▣▣▣ [31] 메인보드 7860 57 05-14
4460 소프트웨어| USB 로 UEFI 와 MBR 로 부팅 되도록 ISO 파일 설치하기 [42] 좋은이웃 7063 57 03-17
XE1.11.6 Layout1.4.8