-
August 21st, 2009, 12:35 PM #1
batch file to reset services, need to set explicit credentials
I'm trying to create a batch file here to STOP and then START services on a remote machine. Currently I have been using the SC command and I tried looking at NET STOP/START a little bit. I have also messed with SysInternals' psexec program but all with no luck. I tried using psexec to launch the batch file contents below but it bombs with an "error code 1" so I have been trying different routes...
I want to create a batch file to ECHO something to the user, they click a button, it'll stop the services, then ECHO something else, then they click a button and then it'll start those services back up. I have sufficient network rights that it works fine for me just using the following:
but this wont work for limited users and I dont want to increase their network rights, this is just while I'm out for vacation. So I want to give it an explicit user that I setup just for this that will have sufficient rights to the service control module on those servers. so I can say the user with the DOMAIN\User context and include the password which I think would work best in double quotes.Code:ECHO This will reset blah blah blah PAUSE sc \\srv1 stop servicename sc \\srv2 stop servicename ECHO Please wait a few seconds and then... PAUSE sc \\srv1 start servicename sc \\srv2 start servicename
Any takers on this, I think I'm just missing something simple, any tricks to doing this that I dont know about?
Mobile: Thinkpad T61 | WinXP Pro | C2D T8300 CPU | 3GB DDR2 | 320GB Hybrid SSD HDD | AGN & WWAN
Desktop: Dell XPS 8300 | 3.4 Ghz Intel i7 | 8GB DDR3 | 1TB OS, 1.5TB Mirrored DATA
-
August 24th, 2009, 08:22 AM #2
bump for the morning...
Mobile: Thinkpad T61 | WinXP Pro | C2D T8300 CPU | 3GB DDR2 | 320GB Hybrid SSD HDD | AGN & WWAN
Desktop: Dell XPS 8300 | 3.4 Ghz Intel i7 | 8GB DDR3 | 1TB OS, 1.5TB Mirrored DATA
-
April 30th, 2010, 09:01 PM #3
Wouldn't it be easier to install webmin and make them an account and permissions there?
DynaIndex.com - Dynamic search index of websites, links, feeds, title, description, keywords and thumbnail snapshot.
-
April 30th, 2010, 09:52 PM #4
Well I use psexec to open firefox and snapshot a thumbnail on a windows box, works for unix too.
psexec.exe and the bat same folder. cmd runs background
Can wrap this in some php code to do what you want. Do normal bat commands in
a command.bat file.
function execInBackground($cmd) {
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}
else {
exec($cmd . " > /dev/null &");
}
exec("Psexec.exe -i -d ./filepath/command.bat ");
Here's the basic command format for the exec.
exec ("psexec -u someusername -p somepassword -c \\\\someipaddressORHostname someprogram.exe");
Hope this helps, I had to play with this a while myself to get working.DynaIndex.com - Dynamic search index of websites, links, feeds, title, description, keywords and thumbnail snapshot.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Batch file to copy/rename file with current time
By jp22382 in forum Applications and Operating SystemsReplies: 2Last Post: May 19th, 2009, 06:25 AM -
Batch file or Script file ???
By AndreL in forum Webmastering and ProgrammingReplies: 3Last Post: September 26th, 2008, 06:14 AM -
Batch File Help...
By S3NTYN3L in forum Applications and Operating SystemsReplies: 3Last Post: November 13th, 2007, 08:12 AM -
Batch file
By Pritesh in forum Technical SupportReplies: 1Last Post: September 23rd, 2003, 01:48 PM -
batch file help
By DVNT1 in forum Technical SupportReplies: 22Last Post: November 18th, 2002, 06:42 PM



LinkBack URL
About LinkBacks



Reply With Quote

uIS4vjlvqDs
IRS Targets Tea Party and Other...