IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Modification du BIOS


Sujet :

VBScript

  1. #1
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut Modification du BIOS
    Bonjour,

    J'ai trouvé ça sur internet en faisant plusieurs recherches :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    '**********************************************************************
    '*** Name: SampleWakeOnLAN.vbs
    '*** Purpose: To Enable the Wake On LAN on a Dell OMCI client.
    '*** Usage: cscript.exe //nologo SampleWakeOnLAN.vbs <systemname>
    '***
    '*** This sample script is provided as an example only, and has not been
    '*** tested, nor is warranted in any way by Dell; Dell disclaims any
    '*** liability in connection therewith. Dell provides no technical
    '*** support with regard to such scripting. For more information on WMI
    '*** scripting, refer to applicable Microsoft documentation.
    '***
    '*** NOTE: Replace <Password> in line 73 (inside the quotes)
    '*** with the correct password if there is any password set in the system.
    '*** If both passwords(Admin and Boot) are set please replace it with Admin Password.
    '*** If there is no password set in the system please leave it as empty.
    '**********************************************************************
     
    Option Explicit
     
    '*** Declare variables
    Dim strNameSpace
    Dim strComputerName
    Dim strClassName
    Dim strKeyValue
    Dim objWMIService
    Dim ColSystem
    Dim objInstance
    Dim oInParams
    Dim returnValue
    Dim strAttributeName(2)
    Dim strAttributeValue(2)
    Dim strAuthorizationToken
     
    '*** Check that the right executable was used to run the script
    '*** and that all parameters were passed
    If (LCase(Right(WScript.FullName, 11)) = "wscript.exe" ) Or _
        (Wscript.Arguments.Count < 1) Then
        Call Usage()
        WScript.Quit
    End If
     
    '*** Initialize variables
    strNameSpace = "root\dcim\sysman"
    strComputerName = WScript.Arguments(0)
    strClassName = "DCIM_BIOSEnumeration"
    strKeyValue = "Root/MainSystemChassis/BIOSSetupParent/BiosSetupWOL"
     
    '*** Retrieve the instance of DCIM_BIOSEnumeration class for the TPM
    Set objInstance = GetObject("WinMgmts:{impersonationLevel=impersonate," &_
        "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_
        strNameSpace & ":" & strClassName & "=" & Chr(34) & strKeyValue & Chr(34))
    WScript.Echo objInstance.CurrentValue(0)
    WScript.Echo objInstance.AttributeName
     
    '*** All possible values for WOL are as follows:
    '*** 1 = Disable
    '*** 2 = Add-in
    '*** 3 = On board
    '*** 4 = LAN
    '*** 5 = PXE boot enable
    '*** 6 = LAN or WLAN
    '*** 7 = WLAN only
     
    If objInstance.CurrentValue(0) = 1 Then
        '*** Here is where you would perform an action such as writing the computer
        '*** name out to a text file or enabling WoL with the following code...
        '*** This section will attempt to set the value to 4 (LAN) as this is the most
        '*** popular for recent Dell systems
        '*** Initialize variables
    '    strClassName = "DCIM_BIOSService"
    '    strAttributeName(0) = objInstance.AttributeName
    '    strAttributeValue(0) = "4"
    '    strAuthorizationToken = "Password"
     
    '    returnValue = 0
        '*** Retrieve the instance of DCIM_BIOSService class 
    '    Set objWMIService = GetObject("WinMgmts:{impersonationLevel=impersonate," &_
    '        "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_
    '        strNameSpace)
    '    Set ColSystem=objWMIService.execquery ("Select * from " & strClassName)
     
    '    For each objInstance in ColSystem    
    '        Set oInParams = objInstance.Methods_("SetBIOSAttributes").InParameters.SpawnInstance_
    '        oInParams.AttributeName = strAttributeName
    '        oInParams.AttributeValue = strAttributeValue
    '        oInParams.AuthorizationToken = strAuthorizationToken
    '        Set returnValue = objInstance.ExecMethod_("SetBIOSAttributes", oInParams)
    '        Exit For
    '    Next
    End If
     
    '*** If any errors occurred, let the user know
    If Err.Number <> 0 Then
        WScript.Echo "Enabling Wake On LAN failed."
    End If
     
    '*** Sub used to display the correct usage of the script
    Sub Usage()
    Dim strMessage
    strMessage = "incorrect syntax. You should run: " & vbCRLF & _
        "cscript.exe /nologo SampleWakeOnLAN.vbs <systemname>"
    WScript.Echo strMessage
    End Sub
    Le problème est qu'il me renvoi cette erreur : "incorrect syntax. You should run: cscript.exe /nologo SampleWakeOnLAN.vbs <systemname>

    Vous auriez une idée ?

    Merci par avance.

  2. #2
    Rédacteur
    Avatar de omen999
    Profil pro
    Inscrit en
    Février 2006
    Messages
    1 296
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2006
    Messages : 1 296
    Points : 3 549
    Points
    3 549
    Par défaut
    bonjour,

    comment as-tu lancé ce script ?

    ce message s'affiche si le script est lancé par le moteur wscript ou si
    le paramètre <systemname> est omis
    nomen omen, nemo non omen - Consultez la FAQ VBScript et les cours et tutoriels VBScript
    le plus terrible lorsqu'une voiture renverse un piéton, c'est que ce sont les freins qui hurlent. (ramón)
    pas de questions techniques par mp

  3. #3
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut
    Citation Envoyé par omen999 Voir le message
    bonjour,

    comment as-tu lancé ce script ?

    ce message s'affiche si le script est lancé par le moteur wscript ou si
    le paramètre <systemname> est omis
    Bonjour,

    J'ai lancé ce script en l'intitulant WakeOnLAn.vbs depuis Windows.

    Ce que j'aimerais c'est ne pas repasser sur l'ensemble du parc informatique pour modifier le paramètre.

    Une idée ?

    Merci beaucoup par avance.

  4. #4
    Modérateur
    Avatar de l_autodidacte
    Homme Profil pro
    Retraité : Directeur de lycée/Professeur de sciences physiques
    Inscrit en
    Juillet 2009
    Messages
    2 415
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Retraité : Directeur de lycée/Professeur de sciences physiques
    Secteur : Enseignement

    Informations forums :
    Inscription : Juillet 2009
    Messages : 2 415
    Points : 5 806
    Points
    5 806
    Par défaut
    Crée un fichier batch(.bat) et mets dedans cscript.exe /nologo SampleWakeOnLAN.vbs <systemname> en remplaçant <systemname> par le nom de la machine cible, ensuite exécute le fichier .bat
    Ne pas oublier le tag si satisfait.
    Voter pour toute réponse satisfaisante avec pour encourager les intervenants.
    Balises CODE indispensables. Regardez ICI
    Toujours utiliser la clause Option Explicit(VBx, VBS ou VBA) et Ne jamais typer variables et/ou fonctions en VBS.
    Vous pouvez consulter mes contributions
    Ne pas oublier de consulter les différentes FAQs et les Cours/Tutoriels VB6/VBScript
    Ne pas oublier L'Aide VBScript et MSDN VB6 Fr

  5. #5
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut
    Citation Envoyé par l_autodidacte Voir le message
    Crée un fichier batch(.bat) et mets dedans cscript.exe /nologo SampleWakeOnLAN.vbs <systemname> en remplaçant <systemname> par le nom de la machine cible, ensuite exécute le fichier .bat
    Bonjour,

    Merci beaucoup pour ton aide, mais comment j'appel mon .vbs depuis le batch ?
    Comment faire pour déployer cette solution à l'ensemble de mon parc sans modifier à chaque fois le nom de la machine dans <systemname> ?

    Encore merci.

  6. #6
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut
    Bonjour,

    Voici mon bat pour appeler le .vbs :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    call "\\server\xxx\Modification du Bios\SampleWakeOnLAN.vbs" "cscript.exe /nologo SampleWakeOnLAN.vbs <nom de l'ordinateur>"
    Malheureusement, j'obtiens toujours cette erreur :

    "incorrect syntax. You should run: cscript.exe /nologo SampleWakeOnLAN.vbs <nom de l'ordinateur>

    Une idée ?

  7. #7
    Modérateur
    Avatar de l_autodidacte
    Homme Profil pro
    Retraité : Directeur de lycée/Professeur de sciences physiques
    Inscrit en
    Juillet 2009
    Messages
    2 415
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Retraité : Directeur de lycée/Professeur de sciences physiques
    Secteur : Enseignement

    Informations forums :
    Inscription : Juillet 2009
    Messages : 2 415
    Points : 5 806
    Points
    5 806
    Par défaut
    On peut modifier le script pour qu'il reconnaisse de lui-même le nom de la machine puis la ligne de commande utilisée sera cscript.exe /nologo SampleWakeOnLAN.vbs qu'on mettra dans un fichier .bat (Maintenant plus besoin de <systemname>)
    En double-cliquant sur ce fichier, il lancera le script en utilisant le "moteur" Csript.exe.
    Les modifications reposent sur la fonction GetMachineName qui recherche le nom de la machine sur laquelle on exécute le script(via le fichier batch)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    '**********************************************************************
    '*** Name: SampleWakeOnLAN.vbs
    '*** Purpose: To Enable the Wake On LAN on a Dell OMCI client.
    '*** Usage: cscript.exe //nologo SampleWakeOnLAN.vbs <systemname>
    '***
    '*** This sample script is provided as an example only, and has not been
    '*** tested, nor is warranted in any way by Dell; Dell disclaims any
    '*** liability in connection therewith. Dell provides no technical
    '*** support with regard to such scripting. For more information on WMI
    '*** scripting, refer to applicable Microsoft documentation.
    '***
    '*** NOTE: Replace <Password> in line 73 (inside the quotes)
    '*** with the correct password if there is any password set in the system.
    '*** If both passwords(Admin and Boot) are set please replace it with Admin Password.
    '*** If there is no password set in the system please leave it as empty.
    '********************************************************************** 
    Option Explicit
     
    '*** Declare variables
    Dim strNameSpace
    Dim strComputerName
    Dim strClassName
    Dim strKeyValue
    Dim objWMIService
    Dim ColSystem
    Dim objInstance
    Dim oInParams
    Dim returnValue
    Dim strAttributeName(2)
    Dim strAttributeValue(2)
    Dim strAuthorizationToken
     
    '*** Check that the right executable was used to run the script
    '*** and that all parameters were passed
    If (LCase(Right(WScript.FullName, 11)) = "wscript.exe" ) Then 'Or _
        '(Wscript.Arguments.Count < 1) Then
     
        Call Usage()
        WScript.Quit
    End If
     
    '*** Initialize variables
    strNameSpace = "root\dcim\sysman"
    strComputerName = GetMachineName 'WScript.Arguments(0)
    strClassName = "DCIM_BIOSEnumeration"
    strKeyValue = "Root/MainSystemChassis/BIOSSetupParent/BiosSetupWOL"
     On Error Resume Next
    '*** Retrieve the instance of DCIM_BIOSEnumeration class for the TPM
    Set objInstance = GetObject("WinMgmts:{impersonationLevel=impersonate," &_
        "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_
        strNameSpace & ":" & strClassName & "=" & Chr(34) & strKeyValue & Chr(34))
    WScript.Echo objInstance.CurrentValue(0)
    WScript.Echo objInstance.AttributeName
     
    '*** All possible values for WOL are as follows:
    '*** 1 = Disable
    '*** 2 = Add-in
    '*** 3 = On board
    '*** 4 = LAN
    '*** 5 = PXE boot enable
    '*** 6 = LAN or WLAN
    '*** 7 = WLAN only
     
    If objInstance.CurrentValue(0) = 1 Then
        '*** Here is where you would perform an action such as writing the computer
        '*** name out to a text file or enabling WoL with the following code...
        '*** This section will attempt to set the value to 4 (LAN) as this is the most
        '*** popular for recent Dell systems
        '*** Initialize variables
    '    strClassName = "DCIM_BIOSService"
    '    strAttributeName(0) = objInstance.AttributeName
    '    strAttributeValue(0) = "4"
    '    strAuthorizationToken = "Password"
     
    '    returnValue = 0
        '*** Retrieve the instance of DCIM_BIOSService class 
    '    Set objWMIService = GetObject("WinMgmts:{impersonationLevel=impersonate," &_
    '        "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_
    '        strNameSpace)
    '    Set ColSystem=objWMIService.execquery ("Select * from " & strClassName)
     
    '    For each objInstance in ColSystem    
    '        Set oInParams = objInstance.Methods_("SetBIOSAttributes").InParameters.SpawnInstance_
    '        oInParams.AttributeName = strAttributeName
    '        oInParams.AttributeValue = strAttributeValue
    '        oInParams.AuthorizationToken = strAuthorizationToken
    '        Set returnValue = objInstance.ExecMethod_("SetBIOSAttributes", oInParams)
    '        Exit For
    '    Next
    End If
     
    '*** If any errors occurred, let the user know
    If Err.Number <> 0 Then
        WScript.Echo "Enabling Wake On LAN failed."
    End If
     
    '*** Sub used to display the correct usage of the script
    Sub Usage()
    Dim strMessage
    strMessage = "incorrect syntax. You should run: " & vbCRLF & _
        "cscript.exe /nologo SampleWakeOnLAN.vbs" '<systemname>"
    WScript.Echo strMessage
    End Sub
    '================================
    Function GetMachineName()
        GetMachineName = CreateObject("Wscript.Network").ComputerName
    End Function
    Ne pas oublier le tag si satisfait.
    Voter pour toute réponse satisfaisante avec pour encourager les intervenants.
    Balises CODE indispensables. Regardez ICI
    Toujours utiliser la clause Option Explicit(VBx, VBS ou VBA) et Ne jamais typer variables et/ou fonctions en VBS.
    Vous pouvez consulter mes contributions
    Ne pas oublier de consulter les différentes FAQs et les Cours/Tutoriels VB6/VBScript
    Ne pas oublier L'Aide VBScript et MSDN VB6 Fr

  8. #8
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut
    Citation Envoyé par l_autodidacte Voir le message
    On peut modifier le script pour qu'il reconnaisse de lui-même le nom de la machine puis la ligne de commande utilisée sera cscript.exe /nologo SampleWakeOnLAN.vbs qu'on mettra dans un fichier .bat (Maintenant plus besoin de <systemname>)
    En double-cliquant sur ce fichier, il lancera le script en utilisant le "moteur" Csript.exe.
    Les modifications reposent sur la fonction GetMachineName qui recherche le nom de la machine sur laquelle on exécute le script(via le fichier batch)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    '**********************************************************************
    '*** Name: SampleWakeOnLAN.vbs
    '*** Purpose: To Enable the Wake On LAN on a Dell OMCI client.
    '*** Usage: cscript.exe //nologo SampleWakeOnLAN.vbs <systemname>
    '***
    '*** This sample script is provided as an example only, and has not been
    '*** tested, nor is warranted in any way by Dell; Dell disclaims any
    '*** liability in connection therewith. Dell provides no technical
    '*** support with regard to such scripting. For more information on WMI
    '*** scripting, refer to applicable Microsoft documentation.
    '***
    '*** NOTE: Replace <Password> in line 73 (inside the quotes)
    '*** with the correct password if there is any password set in the system.
    '*** If both passwords(Admin and Boot) are set please replace it with Admin Password.
    '*** If there is no password set in the system please leave it as empty.
    '********************************************************************** 
    Option Explicit
     
    '*** Declare variables
    Dim strNameSpace
    Dim strComputerName
    Dim strClassName
    Dim strKeyValue
    Dim objWMIService
    Dim ColSystem
    Dim objInstance
    Dim oInParams
    Dim returnValue
    Dim strAttributeName(2)
    Dim strAttributeValue(2)
    Dim strAuthorizationToken
     
    '*** Check that the right executable was used to run the script
    '*** and that all parameters were passed
    If (LCase(Right(WScript.FullName, 11)) = "wscript.exe" ) Then 'Or _
        '(Wscript.Arguments.Count < 1) Then
     
        Call Usage()
        WScript.Quit
    End If
     
    '*** Initialize variables
    strNameSpace = "root\dcim\sysman"
    strComputerName = GetMachineName 'WScript.Arguments(0)
    strClassName = "DCIM_BIOSEnumeration"
    strKeyValue = "Root/MainSystemChassis/BIOSSetupParent/BiosSetupWOL"
     On Error Resume Next
    '*** Retrieve the instance of DCIM_BIOSEnumeration class for the TPM
    Set objInstance = GetObject("WinMgmts:{impersonationLevel=impersonate," &_
        "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_
        strNameSpace & ":" & strClassName & "=" & Chr(34) & strKeyValue & Chr(34))
    WScript.Echo objInstance.CurrentValue(0)
    WScript.Echo objInstance.AttributeName
     
    '*** All possible values for WOL are as follows:
    '*** 1 = Disable
    '*** 2 = Add-in
    '*** 3 = On board
    '*** 4 = LAN
    '*** 5 = PXE boot enable
    '*** 6 = LAN or WLAN
    '*** 7 = WLAN only
     
    If objInstance.CurrentValue(0) = 1 Then
        '*** Here is where you would perform an action such as writing the computer
        '*** name out to a text file or enabling WoL with the following code...
        '*** This section will attempt to set the value to 4 (LAN) as this is the most
        '*** popular for recent Dell systems
        '*** Initialize variables
    '    strClassName = "DCIM_BIOSService"
    '    strAttributeName(0) = objInstance.AttributeName
    '    strAttributeValue(0) = "4"
    '    strAuthorizationToken = "Password"
     
    '    returnValue = 0
        '*** Retrieve the instance of DCIM_BIOSService class 
    '    Set objWMIService = GetObject("WinMgmts:{impersonationLevel=impersonate," &_
    '        "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_
    '        strNameSpace)
    '    Set ColSystem=objWMIService.execquery ("Select * from " & strClassName)
     
    '    For each objInstance in ColSystem    
    '        Set oInParams = objInstance.Methods_("SetBIOSAttributes").InParameters.SpawnInstance_
    '        oInParams.AttributeName = strAttributeName
    '        oInParams.AttributeValue = strAttributeValue
    '        oInParams.AuthorizationToken = strAuthorizationToken
    '        Set returnValue = objInstance.ExecMethod_("SetBIOSAttributes", oInParams)
    '        Exit For
    '    Next
    End If
     
    '*** If any errors occurred, let the user know
    If Err.Number <> 0 Then
        WScript.Echo "Enabling Wake On LAN failed."
    End If
     
    '*** Sub used to display the correct usage of the script
    Sub Usage()
    Dim strMessage
    strMessage = "incorrect syntax. You should run: " & vbCRLF & _
        "cscript.exe /nologo SampleWakeOnLAN.vbs" '<systemname>"
    WScript.Echo strMessage
    End Sub
    '================================
    Function GetMachineName()
        GetMachineName = CreateObject("Wscript.Network").ComputerName
    End Function
    Merci beaucoup pour cette astuce qui va me permettre de déployer sur mon parc.

    Malheureusement, j'obtiens toujours une erreur :

    "incorrect syntax. You should run: cscript.exe /nologo SampleWakeOnLAN.vbs"

    De quoi cela peut venir ? de mon .bat ?

  9. #9
    Modérateur
    Avatar de l_autodidacte
    Homme Profil pro
    Retraité : Directeur de lycée/Professeur de sciences physiques
    Inscrit en
    Juillet 2009
    Messages
    2 415
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Retraité : Directeur de lycée/Professeur de sciences physiques
    Secteur : Enseignement

    Informations forums :
    Inscription : Juillet 2009
    Messages : 2 415
    Points : 5 806
    Points
    5 806
    Par défaut
    Le fichier vbscript est-il dénommé SampleWakeOnLAN.vbs ? Sinon tu le remplaces dans le .bat par le nom que tu lui as donné.
    Les fichiers .vbs et .bat sont-ils dans le même répertoire ?
    Ne pas oublier le tag si satisfait.
    Voter pour toute réponse satisfaisante avec pour encourager les intervenants.
    Balises CODE indispensables. Regardez ICI
    Toujours utiliser la clause Option Explicit(VBx, VBS ou VBA) et Ne jamais typer variables et/ou fonctions en VBS.
    Vous pouvez consulter mes contributions
    Ne pas oublier de consulter les différentes FAQs et les Cours/Tutoriels VB6/VBScript
    Ne pas oublier L'Aide VBScript et MSDN VB6 Fr

  10. #10
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut
    Citation Envoyé par l_autodidacte Voir le message
    Le fichier vbscript est-il dénommé SampleWakeOnLAN.vbs ? Sinon tu le remplaces dans le .bat par le nom que tu lui as donné.
    Les fichiers .vbs et .bat sont-ils dans le même répertoire ?
    J'ai créé un répertoire "Modif Bios" et y ai mis mon .vbs et mon .bat

    Le fichier vbscript est bien dénommé SampleWakeOnLAN.vbs

  11. #11
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut
    Bonjour,

    J'ai tenté ma chance avec un autre .vbs pour modifier le mot de passe cette fois mais le résultat est le même que pour le précédent :

    "incorrect syntax. You should run: cscript.exe /nologo SampleSetAdminPassword.vbs"


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    '**********************************************************************
    '*** Name: SampleSetAdminPassword.vbs
    '*** Purpose: To Set/Change the BIOS Admin password on a Dell OMCI client.
    '*** Usage: cscript.exe //nologo SampleSetAdminPassword.vbs <systemname>
    '***
    '*** This sample script is provided as an example only, and has not been
    '*** tested, nor is warranted in any way by Dell; Dell disclaims any
    '*** liability in connection therewith. Dell provides no technical
    '*** support with regard to such scripting. For more information on WMI
    '*** scripting, refer to applicable Microsoft documentation.
    '***
    '*** NOTE: Replace <old_password> and <new_password> in line 45 and 44
    '*** (inside the quotes) with the desired values.
    '**********************************************************************
     
    Option Explicit
     
    '*** Declare variables
    Dim strNameSpace
    Dim strComputerName
    Dim strClassName
    Dim objInstance
    Dim strAttributeName(2)
    Dim strAttributeValue(2)
    Dim strAuthorizationToken
    Dim returnValue
    Dim objWMIService
    Dim ColSystem
    Dim oInParams
     
    '*** Check that the right executable was used to run the script
    '*** and that all parameters were passed
    If (LCase(Right(WScript.FullName, 11)) = "wscript.exe" ) Or _
    (Wscript.Arguments.Count < 1) Then
    Call Usage()
    WScript.Quit
    End If
     
    '*** Initialize variables
    strNameSpace = "root/dcim/sysman"
    strComputerName = GetMachineName 'WScript.Arguments(0)
    strClassName = "DCIM_BIOSService"
    strAttributeName(0) = "AdminPwd"
    strAttributeValue(0) = "password"
    strAuthorizationToken = "password1"
    returnValue = 0
    '*** Retrieve the instance of DCIM_BIOSService class 
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate," &_
    "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_
    strNameSpace)
    Set ColSystem=objWMIService.execquery ("Select * from " & strClassName)
     
    For each objInstance in ColSystem 
    Set oInParams= objInstance.Methods_("SetBIOSAttributes").InParameters.SpawnInstance_
    oInParams.AttributeName = strAttributeName
    oInParams.AttributeValue = strAttributeValue
    oInParams.AuthorizationToken = strAuthorizationToken
    Set returnValue = objInstance.ExecMethod_("SetBIOSAttributes", oInParams)
    Next
     
    '*** If any errors occurred, let the user know
    If Err.Number <> 0 Then
    WScript.Echo "Change admin password failed."
    End If
     
    '*** Sub used to display the correct usage of the script
    Sub Usage()
    Dim strMessage
    strMessage = "incorrect syntax. You should run: " & vbCRLF & _
    "cscript.exe /nologo SampleSetAdminPassword.vbs" '<systemname>"
    WScript.Echo strMessage
    End Sub
    '================================
    Function GetMachineName()
        GetMachineName = CreateObject("Wscript.Network").ComputerName
    End Function
    Je n'ai plus d'idée pour résoudre cette erreur de syntaxe et d'où peut-elle bien venir !?

  12. #12
    Modérateur
    Avatar de l_autodidacte
    Homme Profil pro
    Retraité : Directeur de lycée/Professeur de sciences physiques
    Inscrit en
    Juillet 2009
    Messages
    2 415
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Retraité : Directeur de lycée/Professeur de sciences physiques
    Secteur : Enseignement

    Informations forums :
    Inscription : Juillet 2009
    Messages : 2 415
    Points : 5 806
    Points
    5 806
    Par défaut
    Si tu avais utilisé le code que j'ai modifié(avec un Copier/Coller), toute cette peine serait épargnée : Les ligne 33 et 34 doivent être remplacées par :
    If LCase(Right(WScript.FullName, 11)) = "wscript.exe" Then.

    Justement, l'erreur vient de l'argument à passer au fichier script qui n'est plus nécessaire avec l'introduction de la fonction GetMachineName.
    Ne pas oublier le tag si satisfait.
    Voter pour toute réponse satisfaisante avec pour encourager les intervenants.
    Balises CODE indispensables. Regardez ICI
    Toujours utiliser la clause Option Explicit(VBx, VBS ou VBA) et Ne jamais typer variables et/ou fonctions en VBS.
    Vous pouvez consulter mes contributions
    Ne pas oublier de consulter les différentes FAQs et les Cours/Tutoriels VB6/VBScript
    Ne pas oublier L'Aide VBScript et MSDN VB6 Fr

  13. #13
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut
    Citation Envoyé par l_autodidacte Voir le message
    Si tu avais utilisé le code que j'ai modifié(avec un Copier/Coller), toute cette peine serait épargnée : Les ligne 33 et 34 doivent être remplacées par :
    If LCase(Right(WScript.FullName, 11)) = "wscript.exe" Then.

    Justement, l'erreur vient de l'argument à passer au fichier script qui n'est plus nécessaire avec l'introduction de la fonction GetMachineName.
    Bonjour,

    Merci beaucoup pour ta réponse.

    Voici le code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    '**********************************************************************
    '*** Name: SampleSetAdminPassword.vbs
    '*** Purpose: To Set/Change the BIOS Admin password on a Dell OMCI client.
    '*** Usage: cscript.exe //nologo SampleSetAdminPassword.vbs <systemname>
    '***
    '*** This sample script is provided as an example only, and has not been
    '*** tested, nor is warranted in any way by Dell; Dell disclaims any
    '*** liability in connection therewith. Dell provides no technical
    '*** support with regard to such scripting. For more information on WMI
    '*** scripting, refer to applicable Microsoft documentation.
    '***
    '*** NOTE: Replace <old_password> and <new_password> in line 45 and 44
    '*** (inside the quotes) with the desired values.
    '**********************************************************************
     
    Option Explicit
     
    '*** Declare variables
    Dim strNameSpace
    Dim strComputerName
    Dim strClassName
    Dim objInstance
    Dim strAttributeName(2)
    Dim strAttributeValue(2)
    Dim strAuthorizationToken
    Dim returnValue
    Dim objWMIService
    Dim ColSystem
    Dim oInParams
     
    '*** Check that the right executable was used to run the script
    '*** and that all parameters were passed
    If LCase(Right(WScript.FullName, 11)) = "wscript.exe" Then
    Call Usage()
    WScript.Quit
    End If
     
    '*** Initialize variables
    strNameSpace = "root/dcim/sysman"
    strComputerName = GetMachineName 'WScript.Arguments(0)
    strClassName = "DCIM_BIOSService"
    strAttributeName(0) = "AdminPwd"
    strAttributeValue(0) = "PlusLong2016"
    strAuthorizationToken = "b!|0p!|d!d"
    returnValue = 0
    '*** Retrieve the instance of DCIM_BIOSService class 
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate," &_
    "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_
    strNameSpace)
    Set ColSystem=objWMIService.execquery ("Select * from " & strClassName)
     
    For each objInstance in ColSystem 
    Set oInParams= objInstance.Methods_("SetBIOSAttributes").InParameters.SpawnInstance_
    oInParams.AttributeName = strAttributeName
    oInParams.AttributeValue = strAttributeValue
    oInParams.AuthorizationToken = strAuthorizationToken
    Set returnValue = objInstance.ExecMethod_("SetBIOSAttributes", oInParams)
    Next
     
    '*** If any errors occurred, let the user know
    If Err.Number <> 0 Then
    WScript.Echo "Change admin password failed."
    End If
     
    '*** Sub used to display the correct usage of the script
    Sub Usage()
    Dim strMessage
    strMessage = "incorrect syntax. You should run: " & vbCRLF & _
    "cscript.exe /nologo SampleSetAdminPassword.vbs" '<systemname>"
    WScript.Echo strMessage
    End Sub
    '================================
    Function GetMachineName()
        GetMachineName = CreateObject("Wscript.Network").ComputerName
    End Function
    En ayant opéré les modifications, j'obtiens toujours le message suivant :

    "incorrect syntax. You should run: cscript.exe /nologo SampleSetAdminPassword.vbs"

    Là, désolé, mais je sèche totalement.

  14. #14
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut
    J'ai tout de même réussi à lancer mon script du début :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    '**********************************************************************
    '*** Name: SampleWakeOnLAN.vbs
    '*** Purpose: To Enable the Wake On LAN on a Dell OMCI client.
    '*** Usage: cscript.exe //nologo SampleWakeOnLAN.vbs <systemname>
    '***
    '*** This sample script is provided as an example only, and has not been
    '*** tested, nor is warranted in any way by Dell; Dell disclaims any
    '*** liability in connection therewith. Dell provides no technical
    '*** support with regard to such scripting. For more information on WMI
    '*** scripting, refer to applicable Microsoft documentation.
    '***
    '*** NOTE: Replace <Password> in line 73 (inside the quotes)
    '*** with the correct password if there is any password set in the system.
    '*** If both passwords(Admin and Boot) are set please replace it with Admin Password.
    '*** If there is no password set in the system please leave it as empty.
    '********************************************************************** 
    Option Explicit
     
    '*** Declare variables
    Dim strNameSpace
    Dim strComputerName
    Dim strClassName
    Dim strKeyValue
    Dim objWMIService
    Dim ColSystem
    Dim objInstance
    Dim oInParams
    Dim returnValue
    Dim strAttributeName(2)
    Dim strAttributeValue(2)
    Dim strAuthorizationToken
     
    '*** Check that the right executable was used to run the script
    '*** and that all parameters were passed
    If (LCase(Right(WScript.FullName, 11)) = "wscript.exe" ) Then 'Or _
        '(Wscript.Arguments.Count < 1) Then
     
        Call Usage()
        WScript.Quit
    End If
     
     
    '*** Initialize variables
    strNameSpace = "root\dcim\sysman"
    strComputerName = GetMachineName 'WScript.Arguments(0)
    strClassName = "DCIM_BIOSEnumeration"
    strKeyValue = "Root/MainSystemChassis/BIOSSetupParent/BiosSetupWOL"
     On Error Resume Next
    '*** Retrieve the instance of DCIM_BIOSEnumeration class for the TPM
    Set objInstance = GetObject("WinMgmts:{impersonationLevel=impersonate," &_
        "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_
        strNameSpace & ":" & strClassName & "=" & Chr(34) & strKeyValue & Chr(34))
    WScript.Echo objInstance.CurrentValue(0)
    WScript.Echo objInstance.AttributeName
     
    '*** All possible values for WOL are as follows:
    '*** 1 = Disable
    '*** 2 = Add-in
    '*** 3 = On board
    '*** 4 = LAN
    '*** 5 = PXE boot enable
    '*** 6 = LAN or WLAN
    '*** 7 = WLAN only
     
    If objInstance.CurrentValue(0) = 1 Then
        '*** Here is where you would perform an action such as writing the computer
        '*** name out to a text file or enabling WoL with the following code...
        '*** This section will attempt to set the value to 4 (LAN) as this is the most
        '*** popular for recent Dell systems
        '*** Initialize variables
        strClassName = "DCIM_BIOSService"
        strAttributeName(0) = objInstance.AttributeName
        strAttributeValue(0) = "4"
        strAuthorizationToken = ""
     
        returnValue = 0
        '*** Retrieve the instance of DCIM_BIOSService class 
        Set objWMIService = GetObject("WinMgmts:{impersonationLevel=impersonate," &_
            "AuthenticationLevel=pktprivacy}\\" & strComputerName & "\" &_
            strNameSpace)
        Set ColSystem=objWMIService.execquery ("Select * from " & strClassName)
     
        For each objInstance in ColSystem    
            Set oInParams = objInstance.Methods_("SetBIOSAttributes").InParameters.SpawnInstance_
            oInParams.AttributeName = strAttributeName
            oInParams.AttributeValue = strAttributeValue
            oInParams.AuthorizationToken = strAuthorizationToken
            Set returnValue = objInstance.ExecMethod_("SetBIOSAttributes", oInParams)
            Exit For
        Next
    End If
     
    '*** If any errors occurred, let the user know
    If Err.Number <> 0 Then
        WScript.Echo "Enabling Wake On LAN failed."
    End If
     
    '*** Sub used to display the correct usage of the script
    Sub Usage()
    Dim strMessage
    strMessage = "incorrect syntax. You should run: " & vbCRLF & _
        "cscript.exe /nologo SampleWakeOnLAN.vbs" '<systemname>"
    WScript.Echo strMessage
    End Sub
    '================================
    Function GetMachineName()
        GetMachineName = CreateObject("Wscript.Network").ComputerName
    End Function
    Je dois avoir un problème dans mon script, qui ne doit pas correspondre à mon BIOS car l'erreur retournée est : Enabling Wake On LAN failed.

    Si malgré tout vous avez une idée.

  15. #15
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut
    Bonjour,

    Savez-vous si dans le script on peut intégrer des caractères spéciaux du mot de passe BIOS (! ; ? -) ? Serait-il reconnu par le BIOS lui-même ?

    J'ai comme l'impression que le mot de passe choisi pour le BIOS est l'élément de blocage.

    Qu'en pensez-vous ?

  16. #16
    Modérateur
    Avatar de l_autodidacte
    Homme Profil pro
    Retraité : Directeur de lycée/Professeur de sciences physiques
    Inscrit en
    Juillet 2009
    Messages
    2 415
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Retraité : Directeur de lycée/Professeur de sciences physiques
    Secteur : Enseignement

    Informations forums :
    Inscription : Juillet 2009
    Messages : 2 415
    Points : 5 806
    Points
    5 806
    Par défaut
    Normalement, il n'y a pas de restriction de caractères dans un mot de passe.
    Ne pas oublier le tag si satisfait.
    Voter pour toute réponse satisfaisante avec pour encourager les intervenants.
    Balises CODE indispensables. Regardez ICI
    Toujours utiliser la clause Option Explicit(VBx, VBS ou VBA) et Ne jamais typer variables et/ou fonctions en VBS.
    Vous pouvez consulter mes contributions
    Ne pas oublier de consulter les différentes FAQs et les Cours/Tutoriels VB6/VBScript
    Ne pas oublier L'Aide VBScript et MSDN VB6 Fr

  17. #17
    Membre à l'essai
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Mars 2013
    Messages
    50
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : Service public

    Informations forums :
    Inscription : Mars 2013
    Messages : 50
    Points : 22
    Points
    22
    Par défaut
    Citation Envoyé par l_autodidacte Voir le message
    Normalement, il n'y a pas de restriction de caractères dans un mot de passe.
    Merci, finalement, le vbs ne donnant aucun résultat concluant, nous passons sur l'ensemble du parc merci à tous pour vos contributions.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [PowerShell] Modification du BIOS
    Par concombremasque75 dans le forum Scripts/Batch
    Réponses: 3
    Dernier message: 09/05/2016, 11h04
  2. Windows 7 embedded et modification BIOS HP
    Par hunyka dans le forum Windows 7
    Réponses: 3
    Dernier message: 05/06/2013, 16h57
  3. [PC fixe] Lors d'une modification du Bios la machine peine à démarrer
    Par wodel dans le forum Ordinateurs
    Réponses: 6
    Dernier message: 08/05/2012, 14h02
  4. [Carte mère] Problème lors de la modification dans le BIOS
    Par wodel dans le forum Composants
    Réponses: 1
    Dernier message: 09/01/2010, 13h42
  5. modification du Bios
    Par yasinfo dans le forum Composants
    Réponses: 5
    Dernier message: 29/01/2007, 22h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo