[COLOR=#4E9A06]'===================
' File: TrustCopyRun.vbs
'===================[/color]
Const SystemFolder= 1
Dim fso 'to be used for file related code
Dim SysFolder
Dim SysFolderPath
dim strUserLogin
Dim RegEdPath
Dim strAppFolder
Dim strAppName
Dim strAppFile
Dim strAppNetworkFile
[COLOR=#4E9A06]
'==============================================================
' edit the values in the next three lines to match your application and network location[/color]
strAppName = "YourApp"
strAppFile = "YourApp.accdb"
strAppNetworkFile = "\\ServerName\AppFolder\YourApp.accdb"
[COLOR=#4E9A06]'==============================================================[/color]
Set fso = wscript.CreateObject("Scripting.FileSystemObject")
Set SysFolder =fso.GetSpecialFolder(SystemFolder)
SysFolderPath= SysFolder.Path
[COLOR=#4E9A06] 'initialize the script shell object[/color]
Set WshShell = WScript.CreateObject("WScript.Shell")
strUserLogin = WshShell.ExpandEnvironmentStrings("%USERNAME%")
strAppFolder = "C:\users\" & strUserLogin & "\" & strAppName
if not fso.FolderExists(strAppFolder) Then
fso.CreateFolder strAppFolder
End If
[COLOR=#4E9A06] 'SNOW4 Office 12[/color]
RegEdPath = "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\"
WshShell.RegWrite RegEdPath ,strAppName
[COLOR=#4E9A06] 'Write the values into the registry[/color]
WshShell.RegWrite RegEdPath & strAppName & "\Path" , "C:\Users\" & strUserLogin & "\" & strAppName & "\"
WshShell.RegWrite RegEdPath & strAppName & "\AllowSubfolders" , 1, "REG_DWORD"
[COLOR=#4E9A06] 'SNOW5 Office 14[/color]
RegEdPath = "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations\"
WshShell.RegWrite RegEdPath ,strAppName
[COLOR=#4E9A06] 'Write the values into the registry[/color]
WshShell.RegWrite RegEdPath & strAppName & "\Path" , "C:\Users\" & strUserLogin & "\" & strAppName & "\"
WshShell.RegWrite RegEdPath & strAppName & "\AllowSubfolders" , 1, "REG_DWORD"
[COLOR=#4E9A06] 'SNOW5 Office 15[/color]
RegEdPath = "HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Access\Security\Trusted Locations\"
WshShell.RegWrite RegEdPath ,strAppName
[COLOR=#4E9A06] 'Write the values into the registry[/color]
WshShell.RegWrite RegEdPath & strAppName & "\Path" , "C:\Users\" & strUserLogin & "\" & strAppName & "\"
WshShell.RegWrite RegEdPath & strAppName & "\AllowSubfolders" , 1, "REG_DWORD"
[COLOR=#4E9A06] 'copy the application file from the network location to the local folder[/color]
fso.CopyFile strAppNetworkFile ,strAppFolder & "\", 1
[COLOR=#4E9A06] 'run the application[/color]
wshshell.Run strAppFolder & "\" & strAppFile
wscript.Quit