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
| Set oShell = CreateObject("WScript.Shell")
SetLocale "en-us" ' do not remove
If (GetOsVersionNumber()<5) Then
Set reseau = CreateObject("wscript.network")
login = reseau.username
reseau.MapNetworkDrive "o:" , "\\fax\Profs$\" & GetUserName
reseau.MapNetworkDrive "p:" , "\\fax\Eleves$"
reseau.MapNetworkDrive "q:" , "\\fax\Pedagogique$"
Else
Set reseau = CreateObject("wscript.network")
login = reseau.username
reseau.MapNetworkDrive "o:" , "\\fax\Profs$\" & login
reseau.MapNetworkDrive "p:" , "\\fax\Eleves$"
reseau.MapNetworkDrive "q:" , "\\fax\Pedagogique$"
Dim theProxy
Set theProxy = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_proxy")
For Each thing In theProxy
thing.SetProxySetting "192.168.50.253","3128"
Next
End If
Function GetOsVersionNumber()
''''''''''''''''''''''''''''''''''''''''
' Determines OS by reading reg val & comparing to known values
' OS version number returned as:
' Windows 9X: 0
' Windows NT4: 4
' Windows 2k: 5
' Windows XP: 5.1
' Windows 2003: 5.2
' Windows x: >5.2
'
''''''''''''''''''''''''''''''''''''''''
Dim oShell, sOStype, sOSversion, GetOsVersionNumberReg
Set oShell = CreateObject("Wscript.Shell")
On Error Resume Next
sOStype = oShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType")
If Err.Number<>0 Then
' Hex(Err.Number)="80070002"
' - Could not find this key, OS must be Win9x
Err.Clear
GetOsVersionNumber = 0
Exit Function
End If
GetOsVersionNumberReg = oShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion")
If Err.Number<>0 Then
GetOsVersionNumber = "Unknown NTx"
Exit Function
End If
SetLocale "en-us" ' do not remove
GetOsVersionNumber = CSng(GetOsVersionNumberReg)
If GetOsVersionNumber > 49 Then
GetOsVersionNumber = CSng(Replace(GetOsVersionNumberReg, ".", ","))
End If
End Function
Function GetUserName()
'Returns the username property of the wshNetwork object
'Use for Win9x (no %username% by default)
On error resume next
Set nwObject=CreateObject("WScript.Network")
While isnull(nwObject.UserName)
Wend
GetUserName=nwObject.UserName
Set nwObject=nothing
End Function |
Partager