Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.bat file to start/stop a service as domain admin 1

Status
Not open for further replies.

Phototechman

IS-IT--Management
May 27, 2009
62
US
Hello,

I've been having an issue with some software we created due to .net4 framework.. In a nutshell my software takes a picture, creates a thumbnail and sends that thumbnail to a server, then it 'should' release the original picture so someone else can use it. I've found out that .net3.5 and .net4.0 have an issue where it doesn't release the file. So this is a huge headache. I've been working with M$ but of course, they are very little help.

Restarting the service I created that works with my program releases the files and my tech's can then use these files again. However, my users are all power users and don't have access to disable services. So right now they have to reboot the PC to release that file.

I've been trying to create a .bat file or something to that effect that would elevate the file as a domain admin, then restart the service as a work around. However, I'm unable to get this to work as a power user. I can run net stop/net start on any service i want as domain admin with no issues of course, but as a power user they don't have the rights and if I add in the domain user password the .bat file won't run properly.

All of our machines are vista 32bit business running on domain.

Any suggestions?
 
Runas makes the user enter in the password, which I don't want them to do. I'm trying to find a way to have a .bat file stop then start a service without having to enter a password.
 
Phototechman,
Can you set the .bat to run as a scheduled task? The schedule can be configured to run under NT Authority as part of the system. That way your users won't need a password.

I don't know if a power user can manually run a scheduled task, however.

Kmills
 
Thats a really good idea, but its totally random when my users will need to run this script. i'm thinking I'm going to have to write some code and have it call on a .ini file or something.
 
You could do something complicated like have it trigger the batch file when a certain file changes. Or just schedule a service restart every 5 minutes? :-/
 
I have written many services in .Net 3.5 (have not done much in 4.0) that writes to log files and/or copies other files. make sure you dispose of any references to it in the code... if you are using any kind of streams, always make sure that that you issue <stream>.flush() and <stream>.dispose() to be sure to release them. Also, have you tried forcing Garbage Collection?
 
Hello,

Forcing the garbage collection did the trick for us.

Thanks for all the help guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top