tags:

views:

86

answers:

1

Hello,

I have a little problem with a simple vbScript. The script has to run 2 action one after the other.

Option Explicit

Dim WshShell
Dim Yesterday
Dim resultat
Dim commande
Dim Jour

Set WshShell = WScript.CreateObject("WScript.Shell")

Yesterday =  DateAdd("d", -2, Date())
resultat = "00001"
resultat = resultat & Right(Year(Yesterday), 2)
Jour = (Datepart("y", Yesterday))

If ((Jour < 100) and (Jour > 9)) Then resultat = resultat & "0" & Jour

If (Jour < 10) Then resultat = resultat & "00" & Jour

If (Jour >= 100) Then resultat = resultat & Jour

resultat = """(&(objectClass=eTGlobalUser)(eTSuspended=0)(eTRoleDN=*)(eTUpdateDate>=" & resultat & "))"""

commande = GetScriptPath() & "PharosGDH.exe /ldapfilter:" & resultat & " /conso"
WshShell.Run commande, 5, true
commande2 = GetScriptPath() & "PharosGDH.exe /all /auditPharos
WshShell.Run commande2, 5, true
WScript.Quit 1

Function GetScriptPath()
    GetScriptPath = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\"))
End Function

Can someone tell me what is wrong please?

Sorry the declaration was missing on the copy/past, And the windows juste shutdown silently, after that i see that result is not has it suposed to be!

+1  A: 

Is this your actual code? There are at least two syntax errors in it:

First syntax error:

commande2 = GetScriptPath() & "PharosGDH.exe /all /auditPharos

There are double quotes missing at the end of the line:

commande2 = GetScriptPath() & "PharosGDH.exe /all /auditPharos"

Second syntax error:

Dim resultat
Dim commande
Dim Jour

The variable "commande2" is used, but not declared. Use:

Dim resultat
Dim commande
Dim commande2
Dim Jour

If this does not fix your problem, as the others have said, please tell us, what the problem is: Error message? Wrong behaviour?

Second attempt

Maybe display the commands used before executing them to be able to check that they contain the right content:

commande = GetScriptPath() & "PharosGDH.exe /ldapfilter:" & resultat & " /conso"
WshShell.Popup commande
WshShell.Run commande1, 5, true
commande2 = GetScriptPath() & "PharosGDH.exe /all /auditPharos"
WshShell.Popup commande
WshShell.Run commande2, 5, true
WScript.Quit 1
NineBerry