강좌 / 팁

윈 도 우 설치된 기본프린터 확인 및 테스트페이지 인쇄 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 - - -
861 소프트웨어| DiskFresh 사용법(HDD,SSD,플래시 데이터 보존) [10] 메리아 2564 8 05-05
860 소프트웨어| [엑셀] 선택된 셀, 행, 열 강조 하기! [13] 무월 2563 28 08-31
859 윈 도 우| 왕초보가 PE만들기 도전 [10] 하늘은높고 2557 15 02-19
858 소프트웨어| 크로미엄 55 버전에서 플래시 사용설정 [10] 스마트(SMART 2557 2 12-15
857 소프트웨어| [포토샵] 인물 누끼따기 외곽선 정리 [12] 무월 2556 37 09-20
856 하드웨어| ASROCK 메인보드에 관하여..... [5] 밤이슬216 2555 5 12-25
855 소프트웨어| 크롬 상단바 상단창 회색으로 되었을때 해결법 [출처] 크롬... [3] 깨블리 2555 5 09-15
854 소프트웨어| TC 9.12 32 비트 및 64 비트용 확장 한국어 메뉴-Windows 1... [13] VenusGirl 2555 16 02-28
853 윈 도 우| PE 업데이트 스크립트 V1.14 [20] 히이이잌 2554 40 10-28
» 윈 도 우| 설치된 기본프린터 확인 및 테스트페이지 인쇄 vbscript [25] 레마클로 2553 23 01-14
851 기 타| [팁] HTTPS Everywhere 확장프로그램 [1] asklee 2551 2 01-21
850 윈 도 우| 자료 mover(파일 첨부) [11] 레마클로 2550 20 01-16
849 소프트웨어| Premiere CS6 강좌 01 비네팅(vignetting)효과 -프레미어 강좌 [4] murimgasa 2542 2 09-25
848 소프트웨어| foobar2000 dsd 설정 [3] 이킁 2541 2 06-07
847 윈 도 우| 인증서 백업 복구 배치파일 [9] 센돔타오르 2540 18 08-05
846 윈 도 우| 기본 앱 브라우저 자동으로변경 [3] Greinke 2539 4 12-02
845 소프트웨어| 레인미터 스킨들 사용법 및 수정방법 간단한 설명입니다.(... [9] 갑파니 2539 14 04-15
844 서버 / IT| 마소 서버2012R2 인텔 I218-V 드라이버 설정하는 방법입니... [3] 쏘가리차차 2538 0 12-29
843 윈 도 우| 버추얼박스(Oracle VM VirtualBox)로 Grub4Dos 부팅 테스트 [9] 조아조아 2538 3 04-23
842 기 타| 윈도우 10 에서 트루타이프 폰트(True Type Font) 복사하여... murimgasa 2532 2 09-28
XE1.11.6 Layout1.4.8