+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Mobile Member ShuckyD's Avatar
    Join Date
    Apr 2005
    Location
    S. Central PA
    Posts
    3,646

    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:
    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
    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.

    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

  2. #2
    Mobile Member ShuckyD's Avatar
    Join Date
    Apr 2005
    Location
    S. Central PA
    Posts
    3,646
    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

  3. #3
    Ultimate Member quickoldcar's Avatar
    Join Date
    Oct 2004
    Location
    NE Pennsylvania
    Posts
    1,005
    Blog Entries
    1
    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.

  4. #4
    Ultimate Member quickoldcar's Avatar
    Join Date
    Oct 2004
    Location
    NE Pennsylvania
    Posts
    1,005
    Blog Entries
    1
    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

  1. Batch file to copy/rename file with current time
    By jp22382 in forum Applications and Operating Systems
    Replies: 2
    Last Post: May 19th, 2009, 06:25 AM
  2. Batch file or Script file ???
    By AndreL in forum Webmastering and Programming
    Replies: 3
    Last Post: September 26th, 2008, 06:14 AM
  3. Batch File Help...
    By S3NTYN3L in forum Applications and Operating Systems
    Replies: 3
    Last Post: November 13th, 2007, 08:12 AM
  4. Batch file
    By Pritesh in forum Technical Support
    Replies: 1
    Last Post: September 23rd, 2003, 01:48 PM
  5. batch file help
    By DVNT1 in forum Technical Support
    Replies: 22
    Last Post: November 18th, 2002, 06:42 PM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews