- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 WMI Code Creator 创建代码以添加联网打印机。
http://img13.imageshack.us/img13/9847/wmicodecreatorwin32prin.png
生成的代码效果很好(无论如何在我的域帐户下):
using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class CallWMIMethod
{
public static void Main()
{
try
{
ManagementClass classInstance =
new ManagementClass("root\\CIMV2",
"Win32_Printer", null);
// Obtain in-parameters for the method
ManagementBaseObject inParams =
classInstance.GetMethodParameters("AddPrinterConnection");
// Add the input parameters.
inParams["Name"] = "\\\\PrintServer\\PrinterName";
// Execute the method and obtain the return values.
ManagementBaseObject outParams =
classInstance.InvokeMethod("AddPrinterConnection", inParams, null);
// List outParams
Console.WriteLine("Out parameters:");
Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
}
}
}
}
但是,我需要将网络打印机添加到本地 PC 帐户,即无权访问\PrintServer 的非域帐户。
在上面的代码中,我可以在哪里输入域用户(服务帐户)的用户名和密码?
我已经在谷歌上搜索了几个小时,但我所能找到的只是一个愚蠢的帖子,上面说如何在远程机器上添加打印机,这不是我想要做的。
(我需要将远程打印机添加到当前 PC,而不是远程 PC。)(需要注意的是登录用户是本地 PC 帐户。)
有人知道如何实现吗?
最佳答案
您可以在打印服务器上创建相同的本地帐户,从而启用对等身份验证...
即pc1 在本地有用户 bob1。使 bob1 成为打印服务器上的用户。
在 pc1 上以 bob1 运行你的 map 程序,你应该能够访问打印机。
这有帮助吗?
否则,网络打印机是针对每个用户的...以具有访问权限(即 runas)的域用户身份运行您的程序是行不通的,因为它只会将打印机映射到用户 session ,而不是您真正想要的 session 。
...这个呢? http://www.codescript.co.uk/wmi_connect_as_another_user.htm
...还是脚本化? http://www.microsoft.com/download/en/details.aspx?DisplayLang=en&id=12028(即使它不适用于 c#,它仍然可以提供 wmi synatx 的东西)
关于C#/.NET : How to add networked printer to a local PC account?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6963152/
我创建了一个 Delphi 服务,负责将 QuckReports 打印到 Printer.Printers 列表中包含的特定打印机。我将打印机名称传递给例程,然后它在 Printer.printers
powershell "get-content foo.txt|Out-Printer" 只要 foo.txt 是英文的,一切都很好(大部分情况下) 如果 foo.txt 包含 unicode 字符,
我将几个zpl文件发送到打印机进行测试,并且工作正常。 之后,我从UPS接收base64编码的zpl数据,并创建一个文件并通过Java小程序将其发送到打印机,现在我发送给它的任何zpl命令或文件都无济
我想在 ZPL 代码中注释行,例如: ^XA ^MMT ^LL0531 ^PW1280 ^LS0 ^FT81,528^A0B,29,28^FH\^FDTEXT^FS //
显然不是: use strict; use warnings; use Data::Printer; my @values = 1 .. 99; p @values[0..9]; 退货 10 docu
我使用 Zebra Designer 创建标签。但是我有一个问题来居中我的元素。 事实上,当我用 Zebra Designer 创建一个文本框时,它有一个固定的长度,当我替换里面的文本时(例如通过一个
我正在使用 Zebra MZ320 打印机来集成黑标。当黑标设置为True时,我面临问题。在纸张上遇到黑标后,打印机进纸2-3行 用于成功校准黑标的命令: ! DF CONFIG.SYS
我正在开发一个 chrome 应用程序,它需要经常与打印机通信,因此我将直接向打印机发送数据而无需打印对话框,因为该 chrome 提供 chrome.printerProvider API。但 ap
我刚刚修改了 Zebra 打印机的标签。我几乎完成了它,但我目前停留在第一行,我在多个站点上阅读了不同的主题,但没有任何帮助我得到我想要的东西。我们的标签是10cm高15cm宽,下面一行需要从中间到边
我知道这很容易解决,但我已经为此奋斗了一个小时。我需要不断从用户那里获取单词,直到他们输入“退出”并将其写入进程中的文件中。但问题是,它出现了“输入单词:”,但是当我输入它并按回车键时,它不会接受它,
我正在尝试在我的打印机 CANON MB5000 上使用 java print 打印一个文本文件。它适用于 Linux 但不适用于 Windows。在 Windows 上,这里支持文档风格: for
我想测试 IPP 应该具备的一些功能(即监控印象数;参见 this question),但我还没有得到硬件。我如何模拟这样的打印机?是否有虚拟 IPP 打印机的代码? 我将在 Linux 或 Wind
从标题可以看出,这个问题过去已经讨论过。我已将之前的帖子作为引用,并尝试在 Zebra 标签打印机上打印位图图像。我无法打印我正在寻找的图像。请不要忽略,因为它已经讨论过了。 请查看下面提到的代码片段
我正在使用 Crystal Reports 将订单打印到 KOT 打印机。我有四台不同的 KOT 打印机。根据分配的相应打印机名称打印项目。 这工作正常,但为了提高打印速度,我选中了“无打印机”选项。
我正在使用 Zebra GT800 标签打印机,标签角色大小为 2.5' * 1.75'。我正在努力使用 ZPL 命令将其调整为内部标签。我尝试使用在 ZPL 的用户指南中阅读的粗体文本中的几个值,但
我的客户端在使用旧的 Brother 打印机从 JAVA 应用程序打印时遇到问题。他得到的异常(exception)是“打印机不接受作业”。 其他应用程序(不是 java 应用程序)设法使用这些打印机
如何为“文本”添加换行符?比如说: Hello World 会变成 Hello World 无论如何,我可以为我的代码添加一个换行符吗? ^FT78,76^A0N,28,28^FH\^FDHello\
当执行powershell cmdlet Get-Printer时,我很好奇它从何处获取信息。它依靠WMI吗?它会解析注册表吗?我遇到过Get-Printer的响应不同于Windows设备和打印机控制
我正在将 ZPL 代码传递给 Zebra 打印机。在这个 ZPL 代码中,我有一部分会生成二维码。 QR 码的值来 self 在为 WM6.5 开发的移动应用程序中使用条形码扫描功能获得的字符串。扫描
我有一卷 5.1cm x 1.6cm(每行两个)的标签,我需要在每行上打印两个不同的标签(expected result),但是 ZPL 格式的打印命令只打印一个标签并送入下一个标签,将相邻的标签留空
我是一名优秀的程序员,十分优秀!