|
Answer» I searched using the search box and USED several different words to try and find each subject but had no luck.
My first question: What is the command to get the profile name that you are logged in as on that computer?
My second question: Is there a way to scan your LAN for computer names that are connected to your LAN?
My third question: Is it possible to generate a random integer in a batch file?
My fourth question: How can I group different arguments in an If statement? I know in Java its || LIKE this: Code: [Select]If (number == 1 || number == 5 || number == 10) where "||" means "or"1 It is in the var %userprofile% . 2. net view (might work) 4. If "%number%" == "1" ( If "%number%" == "5" ( If "%number%" == "10" ( echo do something... goto :eof ) ) )
group it like this should work.
hope it helps uli3] Use this pseudo system variable : %RANDOM% - expands to a random decimal number between 0 and 32767
4] uli -- your structure will only work if %number% is 1 and 5 and 10. This should cope with OR
:: If number == 1 || number == 5 || number == 10 If "%number%" == "1" GoTo GotIt If "%number%" == "5" GoTo GotIt If "%number%" == "10" GoTo GotIt :: Else GoTo NotIt :: EndIf :GotIt echo do something... GoTo :eof :NotIt GoTo :eof
GrahamOh, sorry. Thanks for correcting my mistake.
uliQuote 1 It is in the var %userprofile% . 2. net view (might work) 4. If "%number%" == "1" ( If "%number%" == "5" ( If "%number%" == "10" ( echo do something... goto :eof ) ) )
group it like this should work.
hope it helps uli 1) %userProfile% works except it shows the whole path name (C:\Docs...\username). Is there a way to have it only say the username? 2) net view works nicely. thanks
Quote3] Use this pseudo system variable : %RANDOM% - expands to a random decimal number between 0 and 32767
4] uli -- your structure will only work if %number% is 1 and 5 and 10. This should cope with OR
:: If number == 1 || number == 5 || number == 10 If "%number%" == "1" GoTo GotIt If "%number%" == "5" GoTo GotIt If "%number%" == "10" GoTo GotIt :: Else GoTo NotIt :: EndIf :GotIt echo do something... GoTo :eof :NotIt GoTo :eof
Graham 3) thanks, is there a way to limit to be between 2 CERTAIN numbers? like maybe 50 and 100? or maybe 0 and 100? or something of that nature? 4) is there an actual Else statement in batch programming? so that if the arguments in the previous if statements are false it just does whatever is under the else statement?
sorry for being so needy guys....this WEBSITE might be helpful: http://www.ss64.com/nt/
1. %username%
type set to see the defined variables.
3 & 4 is explained here:
http://www.ss64.com/nt/if.html
hope it helps uli
Thanks Uli, the username thing is exactly what I was looking for
the Else statement thing appears to only work if you download the resource kit and theres nothing about %Random% on the siteHeres another one, now this one may sound a bit silly but:
How do you add an integer variable and an integer together? I cant seem to work it out... maybe im setting my variable wrong in the first place? Code: [Select]set Dollars=0is there some sort of prefix I need to include?
|