Hey folks.

I have some strange logs for some of my user who's getting their network printers through addprinterconnection.

Sometimes users get their printers, sometimes they don't. I sometimes get errors like '3012 no printers were found' and '10 The environment is incorrect'. The last might have been because I was not running script synchronously, that one is probably sorted out. More precise said: errormessages SOMETIMES get returned like mentioned above, but printers are mapped anyway

We use a wmi-function to list out the users mapped printers. Sometimes it returnes all printers, sometimes some, sometimes only the printer gotten from the terminalserver.

And yes, we are using Citrix XenApp 6 on Win 2008 R2, running a published desktop for users, AND FROM THAT DESKTOP EXECUTING THE PROGRAM IN QUESTION, RUNNING IN A SAFE ZONE AS A PUBLISHED APPLICATION.

We have this poorly written program, which is dependent on having a standardprinter available. Due to errors mentioned above, at startup of the application printers might not always be available, and no default printer set.

I havel also added a dummy-printer that is supposed to get mapped if no standardprinter is set

To debug further on, I'm trying to use the cscript prnmngr.vbs on 2008 servers instead.

What I'm trying to do:
Execute a shell statement for each printer I want the user to map, to ensure that the program I use has printers available (and a standardprinter) when it is executed.

For debug purposes I now map printers through a ini-file.

Here's the code i try, but the shell-statement is not right, and that's my main problem right now, can't get this proper.

 PHP:
$ID = left ("%ClientName%", 15) $PrinterList = Split(ReadProfileString('%logonserver%\NETLOGON\PRINTER\Sikker_Sone.ini', $ID, 'Printer'), ';') $DefPrinter = ReadProfileString('%logonserver%\NETLOGON\PRINTER\Sikker_Sone.ini', $ID, 'Standard') debug on For Each $Printer in $PrinterList ;if AddPrinterConnection($Printer) = 0 $rc = 'c:\windows\system32\cscript.exe c:\windows\system32\printing_admin_scripts\en-us\prnmngr.vbs -ac -p ' + '"\\bksi-fp1\+$printer"' shell $rc ;shell "c:\windows\system32\printing_admin_scripts\en-us\cscript " + "-ac " + "\\bksi-fp1\" +$printer $x = WriteLine( 1 , @Time + " ----> " + "Lagt til skriver" + $Printer + @CRLF) ;else $x = WriteLine( 1 , @Time + " ----> " + "Lykkes ikke å legge til skriver" + $Printer + @error + " " + @serror + @CRLF) ;endif


The syntax for the command is: cscript prnmngr.vbs -ac -p "\\printserver\sharedprinter"
The last statement must have double quotes around it.

Any input will be appreciated, and tips for sorting this out - naturally as well \:\)

And one thing more: How does AddPrinterConnection work opposed to what I'm trying here? Maybe it is kind of the same way it works? Anyway... by doing this in a shell, I'm guaranteed that the printer is present when launching tha application.


Cheers - Jon


Edited by Curious (2013-02-19 01:34 PM)
_________________________
I was placed on earth to do a job. Right now I have so much to do, I will never die..