- This topic is empty.
April 15, 2008 at 5:28 am #1133
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.April 15, 2008 at 5:31 am #12681
You need to install the WMI interface from here:
-TTApril 15, 2008 at 5:54 am #12682
cooool…thanks.April 16, 2008 at 2:31 am #12703
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.
i am running the following in my script –
Description=Set Default Printer to PR1
Category=Set Default Printer
; Check OS, User, Free Space
CF “C” “18000”
; Query User then lock workstation
; Run Custom Script
XC “Files*” “C:”
; End lockout
But for some reason the above does not work. any ideas please.April 16, 2008 at 7:35 am #12707
Hard 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?April 16, 2008 at 7:55 am #12711
in 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.April 16, 2008 at 1:53 pm #12717
Ahh, 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!
-TTApril 16, 2008 at 6:08 pm #12724JoeMember
- Total Post: 104
- Legend in Own LunchBox
This 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.
Set objShell = CreateObject("WScript.Shell")
objShell.Run("Reg Load HKUChangeMe " & chr(34) & "C:Documents and SettingsUserNTUser.dat" & chr(34))
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")
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!April 16, 2008 at 11:34 pm #12725
This 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.April 17, 2008 at 5:47 am #12727
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.April 17, 2008 at 7:38 am #12730ConfGenKeymaster
- Total Post: 11375
- Jedi Master
maybe this helps:
CGApril 17, 2008 at 11:53 pm #12739
Thanks 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.April 18, 2008 at 6:01 am #12745ConfGenKeymaster
- Total Post: 11375
- Jedi Master
As 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:
Description=Change Printer to default
MR "default.reg" "user"
and the default.reg file should look like this:
Windows Registry Editor Version 5.00
CGApril 18, 2008 at 1:13 pm #12749NeoMember
- Total Post: 8
If 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”
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.April 20, 2008 at 11:53 pm #12755
Thanks 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.
- You must be logged in to reply to this topic.