Link to home
Start Free TrialLog in
Avatar of ryanpartridge
ryanpartridge

asked on

the goal is to restart print spooler from command line from a diffrent computer.

my print server needs to be restarted at times when admin is gone i woul like to have some one to run a scriptfile at  there workstation to restart this.???????

Avatar of bilbus
bilbus

The whole server?
or just the print service?
use the windows "Scheduled Tasks" program ... set a time for the program to stop the service, and add the batch file

(for whole computer)
creat a bat file that says
.......................................

shutdown -r -t 1

.................................................

(done)

(for just print spooler)
.........................................
net stop "print spooler"
net start "print spooler"
............................................
(done)
Avatar of ryanpartridge

ASKER

just the service.

I need the you to restat server from there work station. network enviorment
With 'PsExec' from the PsTools-Suite this should be possible...

http://www.sysinternals.com/ntw2k/freeware/pstools.shtml

Hope that helps...
ASKER CERTIFIED SOLUTION
Avatar of ajsaasta
ajsaasta

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
can I do this from a machine that does not have admin rights
if so why
you need admin rights on the target (remote) computer where the spooler is being stopped/started
or to be more precise, you'll need to be member of "print operators" group (to which Administrator(s) automaticly belog to.)
Another possibility without giving the user more permissions:

Run the command via a compiled AutoIt-Script (http://www.autoitscript.com/autoit3/).
Just run the command with user/password via this script, right-click the script and choose 'compile script'. You'll get a exe-file which can be run from every machine.  

but isn't every program, script or whatever run within the context of starters security privileges???

You cannot run that .exe and it will not do what supposed to if you dont have sufficient rights to do the task.

In fewer words: if you dont have the rights to run "net stop spooler" you also dont have the rights to do it with "whatever-o-script".
You're right and you're not :)

The key is to run the command within the script with the needed permissions. I don't know if this is possible with the sc-command ('runas sc...' should work), but with the psservice-command from the PS-Tools-Suite (http://www.sysinternals.com/ntw2k/freeware/pstools.shtml) is will work.

The psservice-command can be run with a user- and password-parameter and it's easy to deploy it over the network to the machines, because you only have to copy the files without installation. It's also possible to run the command from a central location via network.

It doesn't matter if this script is executed from a user without sufficent rights as long as the command within the script will be run under another user context which has these rights.
yeah, well... like I said: "every program, script or whatever is run within the context of starters security privileges"

If you start a program with "runas" command then you run the command within the security context of the given user.

Still, my advice to the original question is:

* use "sc" command to control the spooler service
* run the "sc" command whitin such security context that has privileges to do the task
* in this specific case, the user needs to belong to "print operators" security group
Nice discussion. :)

I don't think the user has to be a member of the 'print operators' group in this specific case because if the command within the script will be run with different user rights(who has enough rights to control the service), these rights count and not the right of the user who started the script.

The advantage is that you don't have to give the user itself these rights permanently. As the script is compiled, the user cannot see the username and password of the user with more rights. Further he cannot break out of the script with more rights because the script terminates itself after execution.

well on this "not related to the original question" -topic ;-) my opinion is that W2K3 has enough tools and options and methods to implement correct security schema for users, power users and administrators so there is no need for script-o-matics.

Cheers!