Edit windows service to log on as specific user using a batch script

897
sc \\server config ServiceName obj= Domain\user password= pass

hope it helps.

Share:
897

Related videos on Youtube

Macter
Author by

Macter

Updated on September 18, 2022

Comments

  • Macter
    Macter over 1 year

    I have a classic dice simulation problem, which I'm struggling to implement since I'm new with R syntax. The function (which I have called simu) works as follows:

    1. Start with 0 points
    2. Simulate n random draws of three six-sided dice
    3. For each draw:
      • If sum of three dice >12 --> +1 point
      • If sum of three dice <6 --> -1 point
      • Otherwise (ie sum between 6 and 12):
        • If three dice have same number --> +5 points
        • Otherwise --> 0 points
    4. Return total # of points obtained at the end of n simulations

    Having tried a number of different methods I seem to be pretty close with:

    simu <- function(n){
      k <- 0
      for(i in 1:n) {
        a <- sample(y,1,replace=TRUE)
        b <- sample(y,1,replace=TRUE)
        c <- sample(y,1,replace=TRUE)  
        if ((a + b + c) > 12)  {
          k <- k+1
        } else if ((a + b + c) < 6)  {
          k <- k-1
        } else if ((a == b) & (b == c))  {
          k <- k+5
        } else k <- 0
      }
      return(k)
    }
    

    The problem seems to be that I am failing to iterate over new simulations (for a, b, c) for each "i" in the function.

    • Admin
      Admin over 11 years
      Found the solution, hope it will hope others. From command line: sc \\server config ServiceName obj= Domain\user password= pass
    • Admin
      Admin over 11 years
      Please post your solution as an answer, so that you can accept it and close the question.
    • Rui Barradas
      Rui Barradas over 6 years
      It doesn't look there's anything wrong with the function, you are just resetting k to zero most of the time, so if you call simu(n) with n > 1 the odds are you will get k <- 0. Isn't it that Otherwise 0 points means Otherwise add zero points?
    • Macter
      Macter over 6 years
      You are correct - the last else statement should have been k <- k + 0. Thanks.
  • Rui Barradas
    Rui Barradas over 6 years
    Also, maybe sample(6, 1) will do, in this case it's exactly the same and much simpler and readable. As a bonus, there would be no need for an extra variable y.