Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2014-04-30
8
576 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Recently, I read that Microsoft has analysed statistics for their security intelligence report. It revealed: still, the clear majority of windows users do their daily work as administrator. An administrative account is a burden, security-wise. My ar…
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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