Versions: 95 +So you've got a networked database and you need an easy way of deploying customised desktop shortcuts for it to your users. Here's a cunning method. The basis for this method is the use of Visual Basic scripting in the form of a VBS file - saves you having to build a setup.exe file or anything strenuous like that. Now VBS files have had something of a bad press, mainly because script-kiddies have used them to write viruses. Don't let that put you off. Anyway, create a file in the text-editor of your choice and name it something intelligent like install_production.vbs - note the extension. Now the script shown below does the following:
'Code sample from Accessory http://www22.brinkster.com/accessory
Set WshNetwork = WScript.CreateObject("WScript.Network")
Dim strI
strI = InputBox("Enter your MyApp database username here. If a default has been suggested, please check it before you proceed, " & _
"amending as required." & Chr(10) & Chr(13) & Chr(10) & Chr(13) & "NOTE: leaving this blank cancels the installation!", _
"MyApp shortcut personalisation", WshNetwork.Username)
If Len(strI)>0 Then
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
Dim MyShortcut, DesktopPath, AccessPath
DesktopPath = WSHShell.SpecialFolders("Desktop")
Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\MyApp - production.lnk")
AccessPath = WSHShell.RegRead("HKCR\.mdb\")
AccessPath = WSHShell.RegRead("HKCR\" & AccessPath & "\shell\new\command\")
AccessPath = Replace(Left(AccessPath, InStr(1, AccessPath,"/", 1) -1), """", "")
MyShortcut.TargetPath = AccessPath
MyShortcut.Arguments = "\\myserver\myshare\myfolder\myapp.mdb /wrkgrp \\myserver\myshare\myfolder\system.mdw /user " & strI
MyShortcut.WorkingDirectory = "C:\Program Files\Microsoft Office\Office\"
MyShortcut.WindowStyle = 3 '1=normal, 2=minimised, 3=maximised
MyShortcut.IconLocation = "\\myserver\myshare\myfolder\myapp.ico"
MyShortcut.Save
Msgbox "Installation completed successfully.", 64, "MyApp"
Else
Msgbox "Installation was cancelled.", 48, "MyApp"
End If
Note that your users may get prompted to confirm that they want to run a VBS file, depending on their PC/environment security settings. Like I said before, this is a security measure to help prevent the feeble-minded exploiting the power of Visual Basic scripting to be malicious.
Tweet |
Site requires Javascript and IFRAME support.Visitors:
| |
|
| ||