VB Script that creates shortcuts on remote machines Print
Written by Winfred DeKreij   

'
'
'This script creates a drive mapping to C$ of a list of servers, checks if a certain file exists and creates a
'shortcut in the startup menu to that file, then removes the mapping.
'
'
'


Set wshShell = WScript.CreateObject("WScript.Shell")
Set objNetwork = CreateObject("Wscript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")

linkname = "backinfo.lnk"
strFolder = "Q:\Documents and Settings\All Users\Start Menu\Programs\Startup\"
driveletter = "C"
serverlist = "servers.txt"

Set f = fso.openTextFile(serverlist,1)
do while f.atendofstream = false       
    servername1 = f.readline
    call mapdrive(driveletter, servername1)
    If fso.FileExists("c:\localbin\backinfo.exe") Then
        set oShellLink = wshShell.CreateShortcut(strFolder & linkname)
        oShellLink.TargetPath = "c:\localbin\backinfo.exe"
        oShellLink.Save
    Else
        Wscript.Echo servername1 & " has no c:\localbin\backinfo.exe"
End If
    call removedrive()
loop
f.close

sub mapdrive(driveletter, servername1)
    objNetwork.MapNetworkDrive "Q:", "\\" & servername1 & "\" & driveletter & "$"
end sub

sub removedrive()
    objNetwork.RemoveNetworkDrive "Q:"
end sub

Add your comment

Your name:
Your website:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification: