dtstivo Posted November 16, 2016 Posted November 16, 2016 We currently are running Windows 7 (32BIT) on the entire network and are now testing as small amount of Windows 10 (64BIT). We currently run the below script to install the Go4Schools link on the desktop at login. This works fine for our Windows 7 (32BIT) but on Windows 10 as the program is 32BIT its installed into a Program Files (x86) by default and the location cannot be changed. Obviously for the time being we still need to use the below script but need additional script "if""else" that if the below isn't on the local computer to create the alternative path on the links. set WshShell = WScript.CreateObject("WScript.Shell") strDesktop=WshShell.SpecialFolders("Desktop") set oShellLink=WshShell.CreateShortcut(strDesktop & "\Go4Schools.lnk") oShellLink.TargetPath="C:\Program Files\Hyperspheric Solutions Ltd\GO Login Tool v2\Go.Login.exe" oShellLink.WindowStyle = 1 oShellLink.IconLocation = "\\server_name\apps\Group Policies\go.ico, 0" oShellLink.Description = "Go4Schools" oShellLink.WorkingDirectory = "C:\Program Files\Hyperspheric Solutions Ltd\GO Login Tool v2" oShellLink.Save Any pointers would be very much appreciated. Thank you in advance.
HPlum78 Posted November 16, 2016 Posted November 16, 2016 (edited) $OSVer = [environment]::OSVersion.Version if ($OSVer.Major -like "10") { $WShell = New-Object -ComObject ("WScript.Shell") $ShortCut = $WShell.CreateShortcut($env:USERPROFILE + "\Desktop\Lync.lnk") $ShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office16\Lync.EXE" $ShortCut.WorkingDirectory = "C:\Program Files\Microsoft Office\Office16" $ShortCut.WindowStyle = 1 $ShortCut.IconLocation = "C:\Program Files\Microsoft Office\Office16\Lync.ico, 0" $ShortCut.Description = "Office Lync 2016" $ShortCut.Save() } elseif ($OSver.Major -like "6*") { $WShell = New-Object -ComObject ("WScript.Shell") $ShortCut = $WShell.CreateShortcut($env:USERPROFILE + "\Desktop\Lync.lnk") $ShortCut.TargetPath = "C:\Program Files (x86)\Microsoft Office\Office16\Lync.EXE" $ShortCut.WorkingDirectory = "C:\Program Files (x86)\Microsoft Office\Office16" $ShortCut.WindowStyle = 1 $ShortCut.IconLocation = "C:\Program Files (x86)\Microsoft Office\Office16\Lync.ico, 0" $ShortCut.Description = "Office Lync 2016" $ShortCut.Save() } If I where doing it in PowerShell it would look a little like that, although you could just use a security filter on a GPO and just apply the GPO to the right set of work stations, If you see what I am saying. You could use gp prefs to create the short cut and dispense of the scripts all together. Anyhow that's a few options to consider. Edited November 16, 2016 by HPlum78
ass17 Posted November 16, 2016 Posted November 16, 2016 We currently are running Windows 7 (32BIT) on the entire network and are now testing as small amount of Windows 10 (64BIT). We currently run the below script to install the Go4Schools link on the desktop at login. This works fine for our Windows 7 (32BIT) but on Windows 10 as the program is 32BIT its installed into a Program Files (x86) by default and the location cannot be changed. Obviously for the time being we still need to use the below script but need additional script "if""else" that if the below isn't on the local computer to create the alternative path on the links Any pointers would be very much appreciated. You kinda partially answered your own question by quoting the path "Program Files (x86)". So based on that you could run a check to see if the main EXE exists in a specific path using the environment variables below: Set wshShell = CreateObject("WScript.Shell") pfiles = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%") pfiles86 = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%") So you in essence you would say: Set wshShell = CreateObject("WScript.Shell") pfiles = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%") pfiles86 = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%") Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(pfiles & "\Hyperspheric Solutions Ltd\GO Login Tool v2\Go.Login.exe"") Then 'Do Something ElseIf fso.FileExists(pfiles86 & "\Hyperspheric Solutions Ltd\GO Login Tool v2\Go.Login.exe"") Then 'Do Something End If
ass17 Posted November 16, 2016 Posted November 16, 2016 You kinda partially answered your own question by quoting the path "Program Files (x86)". So based on that you could run a check to see if the main EXE exists in a specific path using the environment variables below: Set wshShell = CreateObject("WScript.Shell") pfiles = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%") pfiles86 = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%") So you in essence you would say: Set wshShell = CreateObject("WScript.Shell") pfiles = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%") pfiles86 = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%") Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(pfiles & "\Hyperspheric Solutions Ltd\GO Login Tool v2\Go.Login.exe"") Then 'Do Something ElseIf fso.FileExists(pfiles86 & "\Hyperspheric Solutions Ltd\GO Login Tool v2\Go.Login.exe"") Then 'Do Something End If
dtstivo Posted November 17, 2016 Author Posted November 17, 2016 Thank you so much coding isn't my strong point so knew what i wanted it to do, but just not how to do it. Thank you again. David
ass17 Posted November 17, 2016 Posted November 17, 2016 (edited) Here is my final example using Google Chrome set WshShell = WScript.CreateObject("WScript.Shell") strDesktop=WshShell.SpecialFolders("Desktop") set oShellLink=WshShell.CreateShortcut(strDesktop & "\Google Chrome.lnk") pfiles = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%" ) pfiles86 = wshShell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%") Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(pfiles & "\Google\Chrome\Application\chrome.exe") Then oShellLink.TargetPath = pfiles & "\Google\Chrome\Application\chrome.exe" oShellLink.WindowStyle = 1 oShellLink.IconLocation = pfiles & "\Google\Chrome\Application\chrome.exe, 0" oShellLink.Description = "Google Chrome" oShellLink.WorkingDirectory = pfiles & "\Google\Chrome\Application" oShellLink.Save ElseIf fso.FileExists(pfiles86 & "\Google\Chrome\Application\chrome.exe") Then oShellLink.TargetPath = pfiles86 & "\Google\Chrome\Application\chrome.exe" oShellLink.WindowStyle = 1 oShellLink.IconLocation = pfiles86 & "\Google\Chrome\Application\chrome.exe, 0" oShellLink.Description = "Google Chrome" oShellLink.WorkingDirectory = pfiles86 & "\Google\Chrome\Application" oShellLink.Save End If Edited November 17, 2016 by ass17
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now