Set objShell = WScript.CreateObject("WScript.Shell")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set objNetwork = WScript.CreateObject("WScript.Network") 
MyUser = objNetwork.UserName
 
if MyUser = "hsepulveda" then
  objShell.run "IEXPLORE.EXE kdscsp07/citrix/metaframexp/default/login.asp?ClientDetection=On"
  ' page to go ->  /http://kdscsp07/citrix/metaframexp/default/login.asp?ClientDetection=On"

  wscript.sleep 10000

   If filesys.FileExists("c:\autom.nfo") Then
    '' -->  Open file, Read UserName & Password 
      Set ts = filesys.OpenTextFile("c:\autom.nfo", 1)
      UN = ts.ReadLine
      PS = ts.ReadLine
      Typing()
   Else
   ''  --> Read UserName & Password, Create file
      UN = InputBox("     Enter your UserName ...") 
      If UN <> "" then
         PS = InputBox("     Enter your Password ...")
         IF PS <> "" then
            Set filetxt = filesys.CreateTextFile("c:\autom.nfo", True) 
            filetxt.WriteLine(UN)
            filetxt.WriteLine(PS)
            filetxt.Close
            Typing()
         End If
      End IF
   End If

Else  
   Set f3 = filesys.GetFile("c:\autom.nfo")
   ' Delete the files.
   f3.Delete
end if

wscript.sleep 6000
objShell.run "IEXPLORE.EXE http://sops/"
wscript.sleep 6000
objShell.run "OUTLOOK.EXE"

Sub Typing()
   wscript.sleep 500
   objShell.sendkeys  UN
   objShell.sendkeys "{TAB}"
   objShell.sendkeys  PS
   objShell.sendkeys "{TAB}"
   objShell.sendkeys "{down}"
   objShell.sendkeys "{TAB}"
   objShell.sendkeys "{ENTER}"
   wscript.sleep 4500
   Tabs(8)
   wscript.sleep 4500
   Tabs(11)
   wscript.sleep 6000
   objShell.sendkeys "%{TAB}"
   Tabs(12)
End Sub


Function Tabs(ByVal x)

for i = 1 to x
  objShell.sendkeys "{TAB}"
next
objShell.sendkeys "{ENTER}"

End Function
