#37571 - 2003-03-07 07:25 PM
if statements
|
howyadoing
Getting the hang of it
Registered: 2002-06-01
Posts: 86
Loc: Cincinnati
|
I have a script that has multiple if else next statements in it. What command would I use to link this to a group with out if ingroup interfering with the other if statements? Example
IF INGROUP (GROUP) do this with other if statements else endif
|
|
Top
|
|
|
|
#37573 - 2003-03-07 07:37 PM
Re: if statements
|
howyadoing
Getting the hang of it
Registered: 2002-06-01
Posts: 86
Loc: Cincinnati
|
This is what I have been working on. IF INGROUP (group) code:
$directory='\\nas1\DFS\SOFTWARE\APPLICATIONS\TEMPLATES' $destination='%appdata%\MICROSOFT\TEMPLATES' $templates=enumdir($directory) FOR EACH $file IN $templates IF NOT Exist('$destination\$file') COPY '$directory\$file' '$destination' ENDIF NEXT FUNCTION enumdir($directory, OPTIONAL $mask, OPTIONAL $subdir) IF $subdir $subdir='/s' ENDIF IF Exist("$directory") $e=wshpipe('%comspec% /c dir "$directory\$mask" /b $subdir',1) FOR $element = 0 TO UBound($e) $e[$element]=Left($e[$element],Len($e[$element])-1) NEXT $enumdir=$e ELSE EXIT 1 ENDIF ENDFUNCTION Function WshPipe($ShellCMD, OPTIONAL $NoEcho) Dim $WshShell, $oExec, $AllOutput, $Exit, $WshExitCode $WshErrorMsg="" $WshShell=CreateObject("WScript.Shell") $oExec=$WshShell.Exec($ShellCMD) While $Exit<>1 Dim $Output Select Case Not $oExec.StdOut.AtEndOfStream $Output=$oExec.StdOut.ReadAll Case Not $oExec.StdErr.AtEndOfStream $Output=$oExec.StdErr.ReadAll $WshErrorMsg = $Output Case 1 $Output=-1 EndSelect If $Output=-1 If $oExec.Status=1 $Exit=1 Endif Else If $NoEcho<>1 ? $Output Endif $AllOutput = $AllOutput + $Output Endif Loop $WshExitCode=$oExec.ExitCode $WshPipe=split($AllOutput,chr(10)) Exit($WshExitCode) EndFunction
ELSE ENDIF
With the IF statments in the middle it will cause a problem. I need a way to run this based on group membership. Can I do something with a variable?
|
|
Top
|
|
|
|
#37576 - 2003-03-07 08:13 PM
Re: if statements
|
howyadoing
Getting the hang of it
Registered: 2002-06-01
Posts: 86
Loc: Cincinnati
|
Thanks LLigetfa that worked great. It does exactly what I wanted it to do.
|
|
Top
|
|
|
|
#37577 - 2003-03-07 09:23 PM
Re: if statements
|
howyadoing
Getting the hang of it
Registered: 2002-06-01
Posts: 86
Loc: Cincinnati
|
I want to do the following. code:
IF INGROUP("NOREVERYONE") AND EXIST ("%appdata%\MICROSOFT\TEMPLATES") <> 0
Is there something special I have to put so that both ingroup and exist have to be true for it to go to the next step? Thanks in advance.
|
|
Top
|
|
|
|
#37579 - 2003-03-07 09:25 PM
Re: if statements
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 957 anonymous users online.
|
|
|