Hi All,
Good day. basically i’m replacing certain user desktop shortcuts to open with chrome and i want to use Bigfix to read the shortcut arguments of the existing shortcut which will be used to create a vbscript, before deleting the shortcut. the shortcuts are located in the desktop folder of the current user.
The script works if i provide the shortcut parameters like name, argument, path and icon path. however, we have had some situations where the shortcut arguments have been customised due to specific user requirements which is why i would like to use the approach of BigFix inspecting the existing shortcut, creating the vbscript and then deleting the old shortcut.
Providing the shorcut arguments as parameters, works, however when trying to use Bigfix relevance to extract the shortcut argument from the previous shortcut, i get a relevance substitution error which i need help fixing.
N|B i get the error at the appendfile olink.arguments section.
Please see section of code below
// set dynamic parameters
action parameter query "SCTarget" with description "Enter 'Current' for Current User or 'All' for All Users." with default value "Current"
action parameter query "SCName" with description "Enter the name for the icon." with default value "Purolator"
action parameter query "SCpath" with description "Enter the path to file" with default value "C:\Program Files (x86)\Google\Chrome\Application"
action parameter query "SCprog" with description "Enter enter the name of the executable in the target path"
action parameter query "SCdesc" with description "Enter enter the shortcut description"
action parameter query "SChotkey" with description "Enter enter the shortcut hotkey"
// set static parameters
parameter "STPIN" = "C:\PortableApps\Shortcuts"
parameter "Startup" = "C:\users\{name of current user}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
parameter "STtask" = "C:\users\{name of current user}\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
if {name of operating system = "Win7"}
parameter "Startmenu" = "C:\users\{name of current user}\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\StartMenu"
delete "C:\Users\{name of current user}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Internet Explorer.lnk"
delete {parameter "Startmenu"}\{parameter "SCName"}.lnk
elseif {name of operating system = "Win10"}
parameter "Startmenu" = "C:\users\{name of current user}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Chrome Apps"
endif
delete {parameter "Startmenu"}\{parameter "SCName"}.lnk
//Select Current User or All Users
if {parameter "SCTarget" of action = "All"}
parameter "Desktop" = "c:\users\Public\Desktop"
else
parameter "Desktop" = "c:\users\{name of current user}\Desktop"
endif
delete __appendfile
delete C:\Temp\replaceshortcut.vbs
appendfile Set oWS = WScript.CreateObject("WScript.Shell")
appendfile sLinkFile = "{parameter "Desktop"}\{parameter "SCName"}.lnk"
appendfile Set oLink = oWS.CreateShortcut(sLinkFile)
appendfile oLink.TargetPath ="{parameter "SCpath"}" & "\{parameter "SCprog"}"
appendfile oLink.Arguments = "{Argument string of shortcut of file "c:\users\" & "(name of current user)" & "\Desktop\" & "(parameter "SCName").lnk" }"
appendfile oLink.Description = "{parameter "SCdesc"}"
appendfile oLink.HotKey = "{parameter "SChotkey"}"
appendfile oLink.IconLocation = "{icon pathname of shortcut of file "(parameter "SCName").lnk" of(folder "c:\users\" & (name of current user )& "\Desktop"))}"
appendfile ' oLink.WindowStyle = "1"
appendfile ' oLink.WorkingDirectory = ""
appendfile oLink.Save
copy __appendfile "C:\Temp\replaceshortcut.vbs"