SetConsole('HIDE')
; Declaring variables ; ## YEAH?? So really declare them!!
;
Dim $PZB ; defines what PZB path will be set within CER.ini
Dim $CER ; defines where our user's CER.ini file is saved too, and looked for
Dim $PFX ; defines the value for PFX for claimsview
Dim $MENU ; defines the value for Menu for Claimsview
Dim $Rc ; Return code catcher
Dim $Path ; path string
Dim $Message ; message header
Dim $MaxSess ; maximum number of allowed sessions
Dim $TaskList ; command to return list of user tasks
Dim $aResult ; array containing STDOUT and STDERR arrays
; ## Get the idea? Declare the rest of the variables, too!
; ## Be consistent with Var Names. I prefer MixedCase for local vars, CAPS for globals and @-Macros
; ## Consistent use of commands improves readability - "WriteProfileString" is easier to recognize than "writeprofilestring"
; ## Not required, but use single quotes for Kix strings so double quotes can easily be embedded. Many
; ## DOS commands require double quotes
; ## Embedding vars and macros in strings is bad - use the form 'text ' + $Var + ' more text ' + @MACRO instead
$Rc = SetOption('NoVarsInString', 'On')
$Rc = SetOption('NoMacrosInString', 'On')
; ## init all vars here
$pzb = '\\root\Production$$'
$cer = '\\root\userconfigs$$\@userid\Production'
$pfx = '0001'
$Menu = 'Y'
$MaxSess = 2
;
;
$Message = ' You are not allowed to run more than two copies of OurApp. '
; ## LOAD THE REQUIRED UDF (or paste it to the end of this file, which is more portable)
; ## if you embed the UDF, delete the next line or you will have a duplicate UDF error
Call '.\WshPipe.udf'
; Checking for Cer.ini, copying it if it's not there.
;
$Path = '\\root\userconfigs$\' + @USERID ; ## NO VARS/MACROS INSIDE STRINGS
IF NOT Exist ($Path)
MD $Path
EndIf
;
IF NOT Exist ($cer + '\cer.ini')
MD $cer ; ## NO QUOTES AROUND VARS
Copy '\\root\' + cer$ + '\cer.ini' $cer
WriteProfileString($cer + '\cer.ini', 'System', 'PzbPath', $pzb)
EndIf
;
WriteProfileString($cer + '\cer.ini', 'CLAIMVIEW', 'PFX', $pfx)
WriteProfileString($cer + '\cer.ini', 'ClAIMVIEW', 'MENU', 'menu')
;
;
$Tasklist='tasklist /FI "Username eq %USERDOMAIN%\%USERID%" /FI "Imagename eq App.exe"'
$aResult=WshPipe($Tasklist)
;
If UBound($aResult[0]) < ($MaxSess +1)
Run 'C:\appname\app\app.exe ' + $cer + '\cer.ini'
Else
MessageBox('$Message',' ***You are not allowed to run more than two App sessions*** ',0,10)
EndIf
;
; ## Specify the exit code - leave nothing to chance
Exit 0