- This topic is empty.
-
AuthorPosts
-
15. April 2008 at 5:28 #1133
hi,
i have installed a few local printers on V90LE and am writing a script to set one as default.
i am using “cscript prnmngr.vbs -t -r (port)” to set default printer. But when i execute this script i get the following error –
prnmngr.vbs(704. 9) SWbemservicesEx: Not Found.
has anyone used this command before and know how to fix this please?
thanks.
15. April 2008 at 5:31 #12681Hi,
You need to install the WMI interface from here:
Cheers,
-TT15. April 2008 at 5:54 #12682cooool…thanks.
16. April 2008 at 2:31 #12703hi,
i have now setup a batch file that will run the cscript prnmngr command to set a default printer in my image.
i have converted the batch file into exe. i have tested the batch file and the executable both running locally on the terminal to see if it works – does work with no problem.
now i have put everything in a rapport script. when i push the package on the client, the script runs with no errors but the default printer is not set.
any ideas?
i am running the following in my script –
[Version]
Number=PR1
Description=Set Default Printer to PR1
OS=XP
Category=Set Default Printer[Script]
;
;
; Check OS, User, Free Space
;
CO “XP”
CF “C” “18000”
;
; Query User then lock workstation
QU
LU*
; Run Custom Script
;
XC “Files*” “C:”
EX “C:DEFPRNdefault.exe””+”
DT “C:DEFPRN”
;;
; End lockout
;
EL*But for some reason the above does not work. any ideas please.
16. April 2008 at 7:35 #12707Hard to say without seeing the contects of the script you have converted to an .exe. Could it be an issue with the fact the .exe runs as the system user?
16. April 2008 at 7:55 #12711in my script i am just running the command as below to set default printer –
cscript prnmngr.vbs -t -p “printername”
Also, i tried to run the batch file (instead of exe) from within the package and also included “pause” command to halt and see the results. It does everything properly and in the end it also says “the default printer has been set to ….” – but does not actually does it.
If i run the same batch file or exe manually directly from the terminal (not thru package) – i get the same “the default printer has been set to ….” – but this time it does change the default printer.
really wierd.
16. April 2008 at 13:53 #12717Ahh, and that’s the problem – the default printer is a user based setting so as the Hagent runs as system user it may be setting the default printer as this user. You will need to explore other ways to set the default printer or call the user you which to run this as, its a common issue with deployment agents so time to Google!
Cheers,
-TT16. April 2008 at 18:08 #12724This may or may not help you, but here is some code that I use to get entries in to the user registry instead of the system users registry.
This is going to go at the beginning of your vbscript. It will actually load the users registry hive and allow you to modify it.
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run("Reg Load HKUChangeMe " & chr(34) & "C:Documents and SettingsUserNTUser.dat" & chr(34))
wscript.echo "Sleeping..."
wscript.sleep 2000
Once this is done, you can access the registry by using HKEY_USERSChangeMe instead of HKEY_CURRENT_USER.
When you are done, you will need to unload the hive using the following code:
objShell.Run("Reg Unload HKUChangeMe")
wscript.echo "Sleeping..."
wscript.sleep 2000
Now, I’m still looking into this, but I have a hunch that it might not work if the script executes while the user is logged in, but I’m having some other problems and can’t confirm that right now. I figured I would just throw it out there just in case it might help you!
16. April 2008 at 23:34 #12725This is so annoying – i must have tried 10 different scripts to set the default printer. All the scripts work when i run them manually on the Wyse unit. Now, when i try and package and push it from Rapport, the script executes successfully but does not set the default printer as required.
Is there some other way of setting a default printer thru rapport package? I will need to create a package to do this because users are not allowed to make any changes on the unit since the write filter is on.
any ideas appreciated please.
thanks.
17. April 2008 at 5:47 #12727Hi Joe,
Thanks for your reply and the code above – but unfortunately this is also not working because as you said if the user is already logged in it will not load the hive.
Cannot believe it would be this difficult just to setup default printer thru Rapport Package.
any more ideas please?
thanks.
17. April 2008 at 7:38 #1273017. April 2008 at 23:53 #12739Thanks ConfGen. I even tried this one but same result.
All the scripts that i tried in all different ways including the tool below works great when you manually execute on the Wyse unit.
When i execute the command on the Wyse unit manually it works great. But, when i execute the same thing thru Rapport Package the script runs successfully and you also get the message that the default printer has been set but does not change it.
Now, i don’t know what is the difference between executing the command manually on the Wyse and thru Rapport package?
I believe this is a user based setting and the user has to be manually set default printer rather than doing thru Rapport script. But i cant make this possible because the write filter is on for users and they cannot save any setting. And this is the reason i am setting the default printer thru script so that the setting is saved.
Is this the way the Rapport Package is designed to work? OR i am doing something wrong.
Thanks and more help and advice appreciated.
18. April 2008 at 6:01 #12745As TT stated before the script are run in the System account.
Do you know the registry setting you have to use to set the default printer?
If yes you should try a WDM script like this:[Version]
Number=DefaultPrinter
Description=Change Printer to default
OS=XP
Category=Other Packages
USE_Pxe=NO
[Script]
CO "XP"
MR "default.reg" "user"
RB
and the default.reg file should look like this:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USERxxxxxxxxxxxxxxxxxxxxxx]
“xxxxxxxxxxxxxx”=”xxxxxxxxxxxxxxxxxxx”Cheers
CG18. April 2008 at 13:13 #12749If this is a problem caused by running as the System account try putting your script to set the default printer in the startup group for the User account and then forcing a logoff/logon sequence with your WDM script without rebooting. This is force the script to be run as the local user, not system, and it will be run before WDM re-enables Write Filter.
So your script would look something like this if your script to set the default printer were called install.bat:
SF “install.bat” “C:Documents and SettingsUserStart MenuProgramsStartupinstall.bat”
EX “shutdown -l -f”
LP “30”
DF “C:Documents and SettingsUserStart MenuProgramsStartupinstall.bat”I had to do something similar a while back with a driver update script I was running. It ran fine if I executed it locally but not if I did it through a WDM script.
20. April 2008 at 23:53 #12755Thanks ConfGen. I tried your script below (MR “default.reg” “user”) but unfortunately i am getting the same result – the script does run but does not change the default printer.
The only way i could fix this problem (as also addressed by Neo below) is saving the file in the startup and it does work – is does change the default printer when the system starts. I guess this is the only way to fix – rest all method failed.
Thanks guys.
-
AuthorPosts
- You must be logged in to reply to this topic.