Share via


Windows 7 的 NET PRINT 指令在哪里?

 如果你习惯下指令来操作系统,那么您可以试试在 Windows 7 的 command line 底下输入 "net /?",你会发现下图:

NET PRINT in Windows 7

耶... 怎么 NET PRINT 的指令不见了?

是的,你没有看错,NET PRINT 指令在 Windows 7 已经不存在了。

为什么呢?根据中国 TechNet 团队特派员的了解,决定不在 Windows 7 继续提供 NET PRINT 指令有两个理由,一是指令的使用率,二是有其他的方式可以达到同样的目的。

在我们开始说明有哪些方式可以达到同样的效果前,先让我们来复习一下 NET PRINT 这个指令吧。

透过 NET PRINT 的指令说明(如下)我们可以知道,NET PRINT 是用来显示当前列印工作排序状态。您可以透过指令来指派列印工作的状态,例如暂停列印工作、恢复列印工作以及删除列印工作。

NET PRINT
\\computername\sharename
          [\\computername] job# [/HOLD | /RELEASE | /DELETE]

NET PRINT displays print jobs and shared queues.  For each queue, the display lists jobs, showing the size and status of each job, and the status of the queue.

  • computername is the name of the computer sharing the printer queue(s).
  • sharename is the name of the shared printer queue.
  • job# is the identification number assigned to a print job.  A computer with one or more printer queues assigns each print job a unique number.
  • /HOLD prevents a job in a queue from printing.  The job stays in the printer queue, and other jobs bypass it until it is released.
  • /RELEASE reactivates a job that is held.
  • /DELETE removes a job from a queue.

虽然 NET PRINT 已经不复存在,但是你在 %windir%\System32\Printing_Admin_Scripts\en-US 找到 prnjobs.vbs 来实现相同的功能。

prnjobs.vbs

 这里要注意的是,如果您想要在command line里下 prnjobs.vbs -? 指令的话,必须向下图这样下:cscript prnjobs.vbs -?

CScript prnjobs.vbs 

底下列出 prnjobs 的指令说明:

Usage: prnjobs [-zmxl?] [-s server][-p printer][-j jobid][-u user name][-w password]

As you can see from the command above, there are several arguments that can be passed to the script:

  • -j is the job id
  • -l is used to list all jobs
  • -m used to resume the job
  • -p used to specify the printer name
  • -s used to specify the server name
  • -u specify the user name of a user (passing admin credentials for example)
  • -w specify the password
  • -x used to cancel a print job
  • -z used to pause a print job
  • -? display command usage / help

如果您想要利用 prnjobs.vbs 来进行打印机的管理,那么我也列出几个常用的指令与过去和 NET PRINT 指令的对照,方便您使用:

作用

NET PRINT 指令

PRNJOBS.VBS 指令

列印工作排序状态

NET PRINT <printer name>

cscript prnjobs.vbs –l –p <printer name>

暂停列印工作

NET PRINT <printer name> <job id> /hold

cscript prnjobs.vbs -p <printer name> -j <job id> -z

恢复列印工作

NET PRINT <printer name> <job id> /release

cscript prnjobs.vbs -p <printer name> -j <job id> -m

删除/取消列印工作

NET PRINT <printer name> <job id> /delete

cscript prnjobs.vbs -p <printer name> -j <job id> -x

上面的对照表示假设您使用的是本机打印机,如果您要管理远端的打印机,请记得加 -s 这个参数。

您也可以透过 PowerShell 脚本以及 WMI 脚本来执行这个指令。

祝大家使用愉快。 

 

参考资料:

  1. Windows 7: No More NET PRINT
  2. Microsoft Script Center 
  3. MSDN: Win32_PrintJob Class