Link to home
Start Free TrialLog in
Avatar of Bianchi928
Bianchi928

asked on

Needs domain\username & password

I'm having a permission problem to get the following script to work.Can someone fix the
script for me

eg strUsername = "domain\username"
     strPassword = "password"


strInputFile = "ComputerUsers.txt"

Dim objShell, objFSO, objInput, strComputer, strUser, objShortcut, strLine
Const ForReading = 1

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objInput = objFSO.OpenTextFile(strInputFile, ForReading, False)
While Not objInput.AtEndOfStream
      strLine = objInput.ReadLine
      If InStr(strLine, ":") > 0 Then
            strComputer = Split(strLine, ":")(0)
            strUser = Split(strLine, ":")(1)
            If Ping(strComputer) = True Then
                  If objFSO.FolderExists("\\" & strComputer & "\C$\Documents and Settings\" & strUser & "\Desktop") = True Then
                        Set objShortcut = objShell.CreateShortcut("\\" & strComputer & "\C$\Documents and Settings\" & strUser & "\Desktop\My_Documents.lnk")
                        objShortcut.Description = "Network Source File Storage"
                        objShortcut.TargetPath = "\\tyrenet-14\transfer\" & strUser & "\my_documents"
                        objShortcut.IconLocation = "C:\Windows\System32\shell32.dll, 19"
                        objShortcut.Save
                  End If
            End If
      End If
Wend
objInput.Close

Function Ping(strComputer)
      Dim objShell, boolCode
      Set objShell = CreateObject("WScript.Shell")
      boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
      If boolCode = 0 Then
            Ping = True
      Else
            Ping = False
      End If
End Function
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bianchi928
Bianchi928

ASKER

All good
Glad to help. Thanks for the grade.

Rob.