Solved

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

Posted on 2014-04-30
8
584 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
[X]
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
  • 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
Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as the high-speed power of the cloud.

 
LVL 16

Author Comment

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

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

Automating Your MSP Business

The road to profitability.
Delivering superior services is key to ensuring customer satisfaction and the consequent long-term relationships that enable MSPs to lock in predictable, recurring revenue. What's the best way to deliver superior service? One word: automation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET Calendar Control 5 54
Batch file to rename files. 12 44
Sending HTML Formatted Email from ASP.NET 2 58
CMD VB Script: remove empty rows 12 14
Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…

752 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