Set objShell = CreateObject( "WScript.Shell" )
Set objFSO = CreateObject("Scripting.FileSystemObject")

rem Nalezneme aktualni Skype profil 
appData=objShell.ExpandEnvironmentStrings("%APPDATA%") & "\skype\shared.xml"

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"
xmlDoc.Load(appData)
Set colNodes = xmlDoc.selectNodes ("/config/Lib/Account/Default")
For Each objNode in colNodes
   strUser = objNode.Text
Next

If IsEmpty(strUser) or IsNull(strUser) Then
	Wscript.echo "POZOR! Uživatel nemá nastaveno automatické přihlašování při spuštění Skype! Program bude ukončen."
	Wscript.quit
end if
wscript.echo "Nalezen uživatel: " & strUser

rem Zkopirujeme konfiguracni 
appData=objShell.ExpandEnvironmentStrings("%APPDATA%") & "\skype\" & strUser & "\config.xml"
dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists(appData) Then
	filesys.CopyFile appData, appData & ".original"
end if


rem Odstranime reklamu a nastavime soubor xml jako read only
Const ForReading = 1
Const ForWriting = 2
Const ReadOnly = 1

Set objFile = objFSO.OpenTextFile(appData, ForReading)

Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    If InStr(strLine, "Advert") = 0 Then
        strNewContents = strNewContents & strLine & vbCrLf
    End If
Loop

objFile.Close

Set objFile = objFSO.OpenTextFile(appData, ForWriting)
objFile.Write strNewContents
objFile.Close
Set objFile = objFSO.GetFile(appData)
objFile.Attributes = ReadOnly

rem Nastavime v registrech nlokovani apps.skype.com
Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
Set objReg=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\apps.skype.com"
objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
strValueName = "https"
' Variable for which zone to include the site in
' 1 - Intranet Sites
' 2 - Trusted Sites
' 3 - Internet Sites
' 4 - Restricted Sites
dwValue = 4
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue

