Problème script batch - setting proxy
Ashina
Messages postés
40
Date d'inscription
Statut
Membre
Dernière intervention
-
Riri -
Riri -
Bonjour,
J'ai un problème avec un script batch. Celui-ci démarre au logon et me demande où je suis. Puis, suivant ma réponse, il doit reconfigurer les paramètres de proxy d'Internet Explorer. Il y a trois locations possibles entre le boulot, l'école et la maison. Seulement, quoique je mette, il me donne systématiquement le message suivant:
Capture d'écran: http://img5.hostingpics.net/pics/518273capture.png
Et ensuite, il fait quand même la configuration pour les locations api et epsic, mais pas pour home. Je ne sais pas pourquoi.
Mon script:
@echo off
cls
set /p choice=Location ?
if '%choice%'=='api' goto api
if '%choice%'=='epsic' goto epsic
if '%choice%'=='home' goto home
' Location : api
:api
@echo off
cls
' Internet Explorer
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d proxy.api.ch:8080 /f
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 00000001 /f
' Mozilla Firefox
' xcopy ".\prefsapi.js" ".C:\Documents and Settings\awichser\Application Data\Mozilla\Firefox\Profiles\heisfaj4.default\prefs.js"
pause
exit
' Location : epsic
:epsic
@echo off
cls
' Internet Explorer
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d proxy.epsic.ch:8080 /f
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 00000001 /f
' Mozilla Firefox
' xcopy ".\prefsepsic.js" ".C:\Documents and Settings\awichser\Application Data\Mozilla\Firefox\Profiles\heisfaj4.default\prefs.js"
pause
exit
' Location : home
:home
@echo off
cls
' Internet Explorer
Reg Add "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]" /v ProxyEnable /t REG_DWORD /d "0" /f
' Mozilla Firefox
' xcopy ".\prefs.js" ".C:\Documents and Settings\awichser\Application Data\Mozilla\Firefox\Profiles\heisfaj4.default\prefs.js"
pause
exit
J'ai également essayé de paramétrer Firefox, mais cela ne fonctionne pas.
Merci pour votre aide.
J'ai un problème avec un script batch. Celui-ci démarre au logon et me demande où je suis. Puis, suivant ma réponse, il doit reconfigurer les paramètres de proxy d'Internet Explorer. Il y a trois locations possibles entre le boulot, l'école et la maison. Seulement, quoique je mette, il me donne systématiquement le message suivant:
Capture d'écran: http://img5.hostingpics.net/pics/518273capture.png
Et ensuite, il fait quand même la configuration pour les locations api et epsic, mais pas pour home. Je ne sais pas pourquoi.
Mon script:
@echo off
cls
set /p choice=Location ?
if '%choice%'=='api' goto api
if '%choice%'=='epsic' goto epsic
if '%choice%'=='home' goto home
' Location : api
:api
@echo off
cls
' Internet Explorer
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d proxy.api.ch:8080 /f
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 00000001 /f
' Mozilla Firefox
' xcopy ".\prefsapi.js" ".C:\Documents and Settings\awichser\Application Data\Mozilla\Firefox\Profiles\heisfaj4.default\prefs.js"
pause
exit
' Location : epsic
:epsic
@echo off
cls
' Internet Explorer
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d proxy.epsic.ch:8080 /f
Reg Add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 00000001 /f
' Mozilla Firefox
' xcopy ".\prefsepsic.js" ".C:\Documents and Settings\awichser\Application Data\Mozilla\Firefox\Profiles\heisfaj4.default\prefs.js"
pause
exit
' Location : home
:home
@echo off
cls
' Internet Explorer
Reg Add "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]" /v ProxyEnable /t REG_DWORD /d "0" /f
' Mozilla Firefox
' xcopy ".\prefs.js" ".C:\Documents and Settings\awichser\Application Data\Mozilla\Firefox\Profiles\heisfaj4.default\prefs.js"
pause
exit
J'ai également essayé de paramétrer Firefox, mais cela ne fonctionne pas.
Merci pour votre aide.
A voir également:
- Script les visiteurs pdf
- Lire le coran en français pdf - Télécharger - Histoire & Religion
- Script vidéo youtube - Guide
- Save as pdf office 2007 - Télécharger - Bureautique
- Télécharger dictionnaire larousse pdf gratuit - Télécharger - Dictionnaires & Langues
- Toutes les formules mathématiques pdf - Télécharger - Études & Formations
2 réponses
Re,
J'ai modifié la méthode... J'ai créé des scripts vbs pour la configuration du proxy suivant le choix de l'utilisateur (voir les scripts ci-dessous).
Cependant, j'ai maintenant deux problèmes:
1) Comment faire un script qui demande un choix, enregistre celui-ci et appelle le fichier suivant ce choix ?
Que ce soit en VBS ou en Batch, je n'en ai aucune idée. J'ai testé deux-trois solutions trouvées sur le net, mais cela ne fonctionne pas. Je dois pouvoir choisir entre le boulot (un proxy), l'école (un autre proxy) et chez moi (pas de proxy).
2) Quelqu'un a-t-il une idée pour répliquer ces paramètres de proxy sur Firefoox ? Ou pour les modifier dynamiquement, comme pour IE ?
Merci beaucoup.
Les scripts:
' On Error Resume Next
'============= paramétrage des paramètres du Proxy ===============
set regmod = CreateObject("WScript.Shell")
'========== Donne l'adresse à utiliser =============
regmod.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer","proxy.api.ch:8080","REG_SZ"
'============ Dit au navigateur d'utiliser le proxy défini =============
regmod.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable",1,"REG_DWORD"
Set objNetwork = CreateObject("Wscript.Network")
' 1. Récupération du nom de l'utilisateur
strUserName = objNetwork.UserName
'==== affichage boîte d'informations =====================
Set WshShell = WScript.CreateObject("WScript.Shell")
intButton = WshShell.Popup (strUsername & ", le Proxy réseau est prêt", , "Internet Explorer - Proxy ON", "64")
Et:
' On Error Resume Next
'============= paramétrage des paramètres du Proxy ===============
set regmod = CreateObject("WScript.Shell")
'========== Donne l'adresse à utiliser =============
'============ Dit au navigateur d'utiliser le proxy défini =============
regmod.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable",0,"REG_DWORD"
Set objNetwork = CreateObject("Wscript.Network")
' 1. Récupération du nom de l'utilisateur
strUserName = objNetwork.UserName
'==== affichage boîte d'informations =====================
Set WshShell = WScript.CreateObject("WScript.Shell")
intButton = WshShell.Popup (strUsername & ", le Proxy est désactivé", , "Internet Explorer - Proxy OFF", "64")
Merci à Jean DSI (https://forums.commentcamarche.net/forum/affich-10754874-activer-desactiver-proxy-internet-soft-ou pour les exemples de scripts.
J'ai modifié la méthode... J'ai créé des scripts vbs pour la configuration du proxy suivant le choix de l'utilisateur (voir les scripts ci-dessous).
Cependant, j'ai maintenant deux problèmes:
1) Comment faire un script qui demande un choix, enregistre celui-ci et appelle le fichier suivant ce choix ?
Que ce soit en VBS ou en Batch, je n'en ai aucune idée. J'ai testé deux-trois solutions trouvées sur le net, mais cela ne fonctionne pas. Je dois pouvoir choisir entre le boulot (un proxy), l'école (un autre proxy) et chez moi (pas de proxy).
2) Quelqu'un a-t-il une idée pour répliquer ces paramètres de proxy sur Firefoox ? Ou pour les modifier dynamiquement, comme pour IE ?
Merci beaucoup.
Les scripts:
' On Error Resume Next
'============= paramétrage des paramètres du Proxy ===============
set regmod = CreateObject("WScript.Shell")
'========== Donne l'adresse à utiliser =============
regmod.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer","proxy.api.ch:8080","REG_SZ"
'============ Dit au navigateur d'utiliser le proxy défini =============
regmod.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable",1,"REG_DWORD"
Set objNetwork = CreateObject("Wscript.Network")
' 1. Récupération du nom de l'utilisateur
strUserName = objNetwork.UserName
'==== affichage boîte d'informations =====================
Set WshShell = WScript.CreateObject("WScript.Shell")
intButton = WshShell.Popup (strUsername & ", le Proxy réseau est prêt", , "Internet Explorer - Proxy ON", "64")
Et:
' On Error Resume Next
'============= paramétrage des paramètres du Proxy ===============
set regmod = CreateObject("WScript.Shell")
'========== Donne l'adresse à utiliser =============
'============ Dit au navigateur d'utiliser le proxy défini =============
regmod.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable",0,"REG_DWORD"
Set objNetwork = CreateObject("Wscript.Network")
' 1. Récupération du nom de l'utilisateur
strUserName = objNetwork.UserName
'==== affichage boîte d'informations =====================
Set WshShell = WScript.CreateObject("WScript.Shell")
intButton = WshShell.Popup (strUsername & ", le Proxy est désactivé", , "Internet Explorer - Proxy OFF", "64")
Merci à Jean DSI (https://forums.commentcamarche.net/forum/affich-10754874-activer-desactiver-proxy-internet-soft-ou pour les exemples de scripts.