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.
Related videos on Youtube
Author by
Macter
Updated on September 18, 2022Comments
-
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:
- Start with 0 points
- Simulate n random draws of three six-sided dice
- 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
- 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 over 11 yearsFound the solution, hope it will hope others. From command line: sc \\server config ServiceName obj= Domain\user password= pass
-
Admin over 11 yearsPlease post your solution as an answer, so that you can accept it and close the question.
-
Rui Barradas over 6 yearsIt doesn't look there's anything wrong with the function, you are just resetting
k
to zero most of the time, so if you callsimu(n)
withn > 1
the odds are you will getk <- 0
. Isn't it thatOtherwise 0 points
meansOtherwise add zero points
? -
Macter over 6 yearsYou are correct - the last else statement should have been k <- k + 0. Thanks.
-
Rui Barradas over 6 yearsAlso, 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 variabley
.