NOW FIXED:
This is my first VB script and it works fine on my PC but not on others with the same version of Windows, etc. It fails to find the destination paths (all in c:/users/USERNAME/appdata... where USERNAME will vary). Any help would be greatly appreciated!
' InstallAddin.vbs
' Get the objects used by this script.
Dim oXL, oAddin, fso, wsh, srcPath, destPath, addin, destPath2, destPath3, addin2, addin3, Wshshell
addin = "\addin.xlam"
addin2 = "\Launcher File.exe"
addin3 = "\Tester File.exe"
Set fso = CreateObject("Scripting.FileSystemObject")
Set wsh = WScript.CreateObject("WScript.Shell")
' Get the current folder.
srcpath = fso.GetFolder(".")
destPath = wsh.Environment("PROCESS")("HOMEDRIVE") & _
wsh.Environment("PROCESS")("HOMEPATH") & _
"\AppData\Roaming\Microsoft\Excel\XLSTART"
destPath2 = wsh.Environment("PROCESS")("HOMEDRIVE") & _
wsh.Environment("PROCESS")("HOMEPATH") & _
"\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
destPath3 = wsh.Environment("PROCESS")("HOMEDRIVE") & _
wsh.Environment("PROCESS")("HOMEPATH") & _
"\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
' Copy the file to the template folder.
fso.CopyFile srcpath & addin, destpath & addin
fso.CopyFile srcpath & addin2, destpath2 & addin2
fso.CopyFile srcpath & addin3, destpath3 & addin3
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run """Launcher File.exe""", 0, False
wshshell.run """Tester File.exe""", 0, False
set wshshell = nothing
x=msgbox("Installation complete!" ,0, "Installation complete")
I fixed it as follows:
usrName = objWShell.expandEnvironmentStrings("%USERNAME%")
destPath = "C:\Users\" & usrName & "\AppData\Roaming\Microsoft\Excel\XLSTART"
destPath2 = "C:\Users\" & usrName & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
destPath3 = "C:\Users\" & usrName & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"