Solved

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

Posted on 2014-04-30
8
563 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 74

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 74

Expert Comment

by:käµfm³d 👽
ID: 40031818
I'm not asking about the file, I'm asking about the net command.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 16

Author Comment

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

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 to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

No security measures warrant 100% as a "silver bullet". The truth is we also cannot assume anything but a defensive and vigilance posture. Adopt no trust by default and reveal in assumption. Only assume anonymity or invisibility in the reverse. Safe…
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.
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now