Printui.dll, PrintUIEntry for installing a driver on a remote machine - winapi

In the help of printui.dll,PrintUIEntry /?, we have the following examples for remotely installing printer driver with the help of /c switch.
Add printer driver using inf:
rundll32 printui.dll,PrintUIEntry /ia /c\\machine /m "Brother DCP-128C" /h "x86" /v "Type 3 - User Mode" /f c:\infpath\infFile.inf
Add printer driver using inf:
rundll32 printui.dll,PrintUIEntry /ia /K /c\\machine /m "Brother DCP-128C" /h "x86" /v 3
I am failing in getting this to work with an error code of 0x32 (This function is not supported). I am doing the following :
Using "net use" to create a connection to the remote server using the remote server's admin credentials.
Disabling the UAC in the remote machine.
Running the above command with and without /K.
I can see that it is copying the driver files into the remote machines "print$" folder but the remote installation finally fails with an error prompt with error code of 0x32.
Is there a way or a specific condition to make this thing work ? Because it is mentioned as an example in the help documentation, I think that I might be missing something.
Are there any other ways to achieve the desired task?

Related

Message Description Popup while sending message to same network in CMD

I want to send message from Dell-PC to Acer-PC
Both are connected to same wifi network.
Dell-PC - Windows 10
Acer-PC - Windows 7
But when ever i use msg command, i get the following:-
The command i use:-
msg /SERVER:Acer-PC * /TIME:20 "Welcome!"
This answer is an hybrid of Batch and VBScript
You will need to enable LocalAccountTokenFilterPolicy value in remote computer:
In that computer open CMD as administrator and type:
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
It should return The operation completed successfully.
Next, create the message box file. For that use a tool called PsExec from Windows Sysinternals
When you have downloaded PsExec, run the following command:
PsExec \\Acer-PC -e CMD /c echo CreateObject("WScript.Shell").Popup "Welcome!",20,"" ^> C:\MessageBox.vbs
To run the message box, type the following from your computer (Acer-PC):
PsExec \\Acer-PC -e WScript.exe C:\MessageBox.vbs
It will appair the message during 20 seconds

Silent printer install via Point-To-Point printing

I'm having trouble with a silent installation script for printers on Windows 10 1709.
We have an installation script that does the following.
Make a connection with the printserver via net use.
Import Point-To-Point registry file
Install the printers
Remove Point-To-Point registry keys and values
This works fine for our Server 2008 computers. I have to do the same trick for Windows 10 1709 computers. Only with a few (not all) printers, i get the following error.
When i install the printer by hand, it works fine. I get a popup that says i have to trust the printer. When i click on install drivers, it installs the printer. It just wont silently install.
Here are the installation scripts.
Install:
echo "Import Point And Print Settings"
reg import PointAndPrint.reg
REM Aanmelden Print Server
net use \\print01\IPC$ /USER:**** *******
echo "Install Printer Drivers"
rundll32 printui.dll PrintUIEntry /in /q /n\\print01\HPLJ-M201n-WSN-Timmerwerkplts
rundll32 printui.dll PrintUIEntry /in /q /n\\print01\Zebra-DIV-VS
rundll32 printui.dll PrintUIEntry /in /q /n\\print01\HPLJ-M127fn-CJG_WSN
rundll32 printui.dll PrintUIEntry /in /q /n\\print01\B8065-Fractiekamer
rundll32 printui.dll PrintUIEntry /in /q /n\\print01\BrotherQL720NW
rundll32 printui.dll PrintUIEntry /in /q /n\\print01\MP2401-GKW-PLOTTER
echo "Import Point and Print"
reg import RemovePointAndPrint.reg
Registry:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint]
"Restricted"=dword:00000001
"TrustedServers"=dword:00000001
"ServerList"="PRINT01;PRINT01.domain.local"
"InForest"=dword:00000001
"NoWarningNoElevationOnInstall"=dword:00000001
"UpdatePromptSettings"=dword:00000002
I used Procmon to see what happended when you "Trust the printserver" if you manually installed it.
This registry setting was set:
[HKEY_CURRENT_USER\Printers\LegacyPointAndPrint]
"DisableLegacyPointAndPrintAdminSecurityWarning"=dword:00000001

Remotely adding printer with batch file ; 0x32 This operation is not supported

I am trying to add a network printer via batch file, provided I feed the data(Printer IP, Printer Name, Computer IP) into the entries.
rundll32 printui.dll,PrintUIEntry /if /b "KONICA MINOLTA C451 PS(P)" /c\\%computerNameIP% /h "x86" /f %windir%\inf\prnkm002.inf /r "IP_%computerNameIP%" /m "KONICA MINOLTA C451 PS(P)" /n\\%computerNameIP%\%printerName% /F %windir%\inf\prnkm002.inf
Now, once this command is completed, I receive the following error:
Operation could not be completed(error 0x00000032). This operation is not supported.
I ran a similar code with runs the GUI:
rundll32 printui.dll,PrintUIEntry /il /b "KONICA MINOLTA C451 PS(P)" /c\\%computerNameIP% /h "x86" /f %windir%\inf\prnkm002.inf /r "IP_%computerNameIP%" /m "KONICA MINOLTA C451 PS(P)" /n\\%computerNameIP% \%printerName% /F %windir%\inf\prnkm002.inf
and I have to choose a local local Printer: which I adjust to be TCP/IP and the drivers come default since I set it. After choosing my driver, I receive the error as well.
I just can't pinpoint what exactly isn't supported.
Windows 7 32-bit. I made adjustments to the registry, print management, group policy, but none of those seem concrete to what is preventing a remote add to a network printer.
I found another way to do it with the prncnfg.vbs files. First create the port, assign it, then manage it.
This is all located in the admin scripts in Windows folder

Add printer Windows 8 programmatically

I am working on a Virtual Printer and I'm stuck at printer installation. Installation is made by InnoSetup
[run] Filename : rundll32.exe; Parameters: "printui.dll, PrintUIEntry /if /f ""{app}\ghostscript\ghostpdf.inf"" /r ""TitusVirtualPrinter:"" /m ""Ghostscript PDF"" /b ""Virtual Printer"" /u /Y "; StatusMsg: Installing PS Printer for Ghostscript; Description: Ghostscript PS Printer; Flags: waituntilterminated shellexec;
That line works perfectly and the program installs on Windows 7 systems (Pro 32&64bits) but not in Windows 8. I don't have any error message.
could it be the same as this:
http://www.jenovarain.com/2012/12/ghostscript-printer-on-windows-8-64-bit/
perhaps they key information in that article relating to your problem is
you will want to select option #7 “Disable Driver Signature
Enforcement”

How disable and enable usb port via command prompt?

How disable and enable usb port via command prompt? or using batch script ? or using vb script in windows 7?
You can use batch which gives you a couple of options. You can edit the registry key to disable usb devices from being used
reg add HKLM\SYSTEM\CurrentControlSet\Services\UsbStor /v "Start" /t REG_DWORD /d "4" /f
To enable change value to 3.
Or you can deny access to the files Usbstor.pnf and Usbstor.inf
cacls %windir%\Inf\Usbstor.pnf /d user
cacls %windir%\Inf\Usbstor.inf /d user
Where user is the user account that you want to deny access for.
To enable use
cacls %windir%\Inf\Usbstor.pnf /p user:R
cacls %windir%\Inf\Usbstor.inf /p user:R
Both commands will need admin rights.
Hope this helps
You can also have a look at devcon command. Available freely on microsoft site, for win7+ windows.
I have the same problem and I use a solution that takes the best of the two previous answers:
1º-We disable the functionality that allow us to detect new external storage devices:
reg add HKLM\SYSTEM\CurrentControlSet\Services\UsbStor /v "Start" /t REG_DWORD /d "4" /f
2º-We remove all the drivers of USB devices installed on the PC (This will also eliminate the possibility of using keyboard and mouse, but only momentarily):
devcon.exe remove *USB*
3º- We re-scan the connected USB devices, so that Windows will automatically install the drivers of devices different than external storage (eg Mouse, keyboard ...), thus obtaining the desired result:
devcon.exe rescan
4º- If we want to re-allow the use of external storage devices in our PC, we must use the command:
reg add HKLM\SYSTEM\CurrentControlSet\Services\UsbStor /v "Start" /t REG_DWORD /d "3" /f
PD: Every command will need admin rights
I use USBDeview. See documentation and examples to use it. Easy and works fine

Resources