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
2009-11-01 07:24:39
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
2009-11-01 07:43:37
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
2009-11-01 08:14:26
Yes, I'm using xamp and I'm running the project on my system.
Ali Bozorgkhan
2009-11-01 08:28:10
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
2009-11-01 12:06:53
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
2009-11-01 12:08:18
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
2009-11-01 22:17:43
Agreed, Apache/Nobody user has very limited permissions
Phill Pafford
2009-11-02 13:29:10