Solved

Run .bat file from ASP.net to restart print spooler

Posted on 2014-04-30
8
571 Views
Last Modified: 2014-06-11
hi all

i write a small batch file (.bat) contains two line to restart the Print spooler service
net stop "Print spooler"
net start "Print Spooler"

Open in new window


and from my asp.net page once i click on a button im running this code:
dim myprocess as new system.diagonastics.process
myprocess .startinfo=new processStartInfo("path to bat file")
myprocess.Start()
myprocess .Close()

Open in new window


when i run this and debug it it run fine without any error but actually the print spooler is not affected at all
0
Comment
Question by:Kamal Khaleefa
  • 4
  • 2
8 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40031808
Does the user that is running you app pool have rights to run the net command?
0
 
LVL 16

Author Comment

by:Kamal Khaleefa
ID: 40031814
the application pool has full control over the file
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40031818
I'm not asking about the file, I'm asking about the net command.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 16

Author Comment

by:Kamal Khaleefa
ID: 40032029
How i can check that?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40039199
In default configs, only Power Users and Administrators are allowed to control services. So check if the App Pool owner is in one of those groups - but be aware that this allows for many other things, too, and is a severe security vulnerability!

It is better to just assign privileges to restart this specific service. You can do that with e.g. subinacl or ntrights, both need to be downloaded first (part of the Windows Resource Kits). I'll show for subinacl (see http://support.microsoft.com/kb/288129 for reference):
subinacl /service "Print Spooler" /grant=DomainOrPC\AppPoolUser=TOI

Open in new window

This needs to be executed as admin, and assigns start/stop/query privilege for the spooler service only.
0
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 0 total points
ID: 40118211
HI EE

i found an alternative solution for this to avoid all security issues

from our asp.net application ,i add a button with name restart Printers

once u click this button i will add a value to a table in the database

then i create an exe file and add it to task schedule that check the database
and if there is a value it will run the bat file from the exe
0
 
LVL 16

Author Closing Comment

by:Kamal Khaleefa
ID: 40126662
this is was the solution that worked for me to avoid all security issues

thanks for all
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SHARE your personal details only on a NEED to basis. Take CHARGE and SECURE your IDENTITY. How do I then PROTECT myself and stay in charge of my own Personal details (and) - MY own WAY...
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question