My problem is this. Iam trying to create a shortcut for a Client Access
session (.ws file). However when I add the path to the actual .ws file
into the TargetPath part, it seems the shortcut doesnt recognize the
path unless I manually edit a piece of the target path. Once I delete
and recreate a character it works just fine. Any help will be greatly
appreciated. Here is the script:
Dim WSHShell
Dim Shortcut, Desktop, DesktopPath
Set WSHShell = WScript.CreateObject("WScript.Shell")
DesktopPath = WSHShell.SpecialFolders("Desktop")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objNetworkPrinter = CreateObject("WScript.Network")
Set objNetworkDrive = Createobject("Wscript.Network")
set oParent = getObject (oUser.parent)
Dim gDomainName, gUsername, gFullname
Dim oNetwork
Dim oGroupList
Dim strQuotationmark
Dim WSPath
Dim CAPath
Dim Space
Dim PPath
gUsername = ""
gDomainName = "domain"
strQuotationmark = """"
WSPath = Chr(34) + "g:\CAccess\%clientname%\caccess1.ws"
CAPath = "C:\Program Files\IBM\Client Access\Emulator\pcsws.exe" +
Chr(34)
PPath = Chr(34) + "g:\CAccess\%clientname%\caccessp.ws"
Space = " "
Set ONetwork = createObject("wscript.network")
Set oGroupList = CreateObject("Scripting.Dictionary")
Call LoadNTGroups() 'also assigns gUsername
If InGroup("domain users") Then
'Wscript.Echo
End if
If InGroup("Session_users") Then
Set Shortcut = WSHShell.CreateShortcut(DesktopPath &
"\Session.lnk")
Shortcut.TargetPath = CAPath & Space & WSPath
Shortcut.WorkingDirectory ="C:\Program Files\IBM\Client
Access\Emulator"
Shortcut.WindowStyle = 4
Shortcut.IconLocation = "C:\Program Files\IBM\Client
Access\Emulator\pcsws.exe,0"
Shortcut.Save
'Else
'fso.delete (DesktopPath & "\Session.lnk")
End If
If InGroup("Session_users") Then
Set Shortcut = WSHShell.CreateShortcut(DesktopPath &
"\Printer.lnk")
Shortcut.TargetPath = CAPath & Space & PPath
Shortcut.WorkingDirectory ="C:\Program Files\IBM\Client
Access\Emulator"
Shortcut.WindowStyle = 4
Shortcut.IconLocation = "C:\Program Files\IBM\Client
Access\Emulator\pcsws.exe,0"
Shortcut.Save
'Else
'fso.delete (DesktopPath & "\Printer.lnk")
End If
'========================
Sub LoadNTGroups()
'
' Load oGroupList (Dictionary) with user's NT group membership...
'
'========================
Dim oUser
Dim oGrp
On Error Resume Next
While gUsername = ""
Err.Clear: gUsername = oNetwork.username
If Err Then WScript.Sleep 100
Wend
On Error Goto 0
Set oUser = GetObject("WinNT://" & gDomainName & "/" & gUsername)
gFullname = oUser.Fullname
oGroupList.CompareMode = vbTextCompare
For Each oGrp In oUser.Groups
oGroupList(oGrp.name) = True
Next
End Sub
'========================
'
Function InGroup(sGroup)
'
' Emulates the KIX InGroup function...
'
'========================
InGroup = oGroupList.Exists(sGroup)
End Function