views:

155

answers:

1

Hi All, I am using exec function to run a bat file and change the default printer. exec file is doing fine, bat file alone is doing fine, but the printer doesn't change when I'm calling the bat file via exec function. I put "echo 1" in the bat file. Browser showed "1" but my printer didn't change. I really need a miracle to solve this !! my OS is Microsoft Server 2003. any ideas?

+1  A: 

Sounds like a permissions issue. The user your web server is running as can run the batch file, but the batch file doesn't have permissions to change the printer (and is failing quietly).

Matthew Scharley
I don't think its the permission issue because I ran the bat file and it changed the default printer. It's just doesn't work from exec function.
Ali Bozorgkhan
If, as it would seem from your comment on the question, you are trying to change the local settings, this is quite impossible (unless your web server is running on `localhost` of course).
Matthew Scharley
Yes, I'm using xamp and I'm running the project on my system.
Ali Bozorgkhan
Then I'm going to have to stick with my original answer. The user that apache is running as is likely an unprivileged user and can't modify system settings, like the default printer. When you run the batch yourself, you are running it as your own user, which does have permission to do that sort of thing.
Matthew Scharley
There's also potentially timing issues involved, depending on what you're trying to achieve and how, but that's something else, and I don't think that's the problem.
Matthew Scharley
Also, you may be trying to change the default printer for the current user, which is succeeding, but again, Apache is running as a seperate user, so it won't affect Firefox.
Matthew Scharley
Agreed, Apache/Nobody user has very limited permissions
Phill Pafford