Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login script

Status
Not open for further replies.

MarBra

IS-IT--Management
Aug 21, 2013
7
US
Need to combine a script to pin icons for Windows XP users and Window 7 Users. The same user would be logging into both machines. This is in a school the students have to have a locked down desktop with specific icons in the start menu. The only problem is I need it to work for each machine a user logs into. I have included the script for the window 7 and the XP.

What needs to run on a window 7 machine
Dim ObjFolder, ObjFolderItem, colVerbs, objverb, objshell

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.Namespace("C:\Program Files\Internet Explorer")
Set objFolderItem = objFolder.ParseName("iexplore.exe")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next

Set objFolder = objShell.Namespace("C:\Windows\System32")
Set objFolderItem = objFolder.ParseName("Notepad.exe")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next

Set objFolder = objShell.Namespace("C:\Program Files (x86)\Google\Google Earth\client")
Set objFolderItem = objFolder.ParseName("googleearth.exe")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next

Set objFolder = objShell.Namespace("C:\Program Files (x86)\SMART Technologies\Education Software")
Set objFolderItem = objFolder.ParseName("notebook.exe")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next

Set objFolder = objShell.Namespace("C:\Program Files (x86)\Google\Chrome\Application")
Set objFolderItem = objFolder.ParseName("chrome.exe")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next

Set objFolder = objShell.Namespace("C:\Program Files (x86)\Microsoft Office\Office14")
Set objFolderItem = objFolder.ParseName("Excel.exe")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next

Set objFolder = objShell.Namespace("C:\Program Files (x86)\Microsoft Office\Office14")
Set objFolderItem = objFolder.ParseName("Winword.exe")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next

Set objFolder = objShell.Namespace("C:\Program Files (x86)\Microsoft Office\Office14")
Set objFolderItem = objFolder.ParseName("Powerpnt.exe")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next

WScript.Quit

What needs to run on windows xp
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Windows\System32")
Set objFolderItem = objFolder.ParseName("Notepad.exe")
objFolderItem.InvokeVerb("P&in to Start Menu")

Set objFolder = objShell.Namespace("C:\Program Files\Internet Explorer")
Set objFolderItem = objFolder.ParseName("iexplore.exe")
objFolderItem.InvokeVerb("P&in to Start Menu")

Set objFolder = objShell.Namespace("C:\Program Files\Google\Chrome\Application")
Set objFolderItem = objFolder.ParseName("chrome.exe")
objFolderItem.InvokeVerb("P&in to Start Menu")

Set objFolder = objShell.Namespace("C:\Program Files\Microsoft Office\Office14")
Set objFolderItem = objFolder.ParseName("Excel.exe")
objFolderItem.InvokeVerb("P&in to Start Menu")

Set objFolder = objShell.Namespace("C:\Program Files\Microsoft Office\Office14")
Set objFolderItem = objFolder.ParseName("Winword.exe")
objFolderItem.InvokeVerb("P&in to Start Menu")

Set objFolder = objShell.Namespace("C:\Program Files\Microsoft Office\Office14")
Set objFolderItem = objFolder.ParseName("powerpnt.exe")
objFolderItem.InvokeVerb("P&in to Start Menu")

Set objFolder = objShell.Namespace("C:\Program Files\SMART Technologies\Education Software")
Set objFolderItem = objFolder.ParseName("Notebook.exe")
objFolderItem.InvokeVerb("P&in to Start Menu")

 
Since your need is limited to Windows XP and Win7 this should do the trick. The thing you are wanting to do is determine, when the program is executed, which OS is running. Fortunately, Windows plugs an OS value into the registry at run time so all you really need to read the value that's already there. Once you have fetched the OS value from the registry you can use a Select/Case statement to either execute your XP code or execute your WIN 7 code.



Dim objRegistry, OS
Set objRegistry = GetObject("Winmgmts:root\default:StdRegProv")
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,"Software\Microsoft\Windows NT\CurrentVersion","CurrentVersion",OS
Select Case (OS)
Case 5.1
'Put your code that pertains to XP here
Case 6.1
'Put your code that pertains to Win 7 here.
Case Else
End Select
 

Some computers have powerpoint some do not. How can I have my script check if powerpoint is installed pin to the start menu if not installed ignore.


Set objFolder = objShell.Namespace("C:\Program Files (x86)\Microsoft Office\Office14")
Set objFolderItem = objFolder.ParseName("Powerpnt.exe")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Start Menu" Then objVerb.DoIt
Next
 
Your first question dealt with determining which OS is running on the PC but the code you have in your subsequent thread was specific to Windows 7. Is this really the case that only Windows 7 machines have PowerPoint or can PowerPoint exist on an XP machine? If PowerPoint is only on Windows 7 machines I would just check for PowerPnt.Exe and place this code in the Case 6.1 in the select after the other code you've put there. If PowerPoint can be on either Win7 or XP machines then I would suggest you use the folder exists and file exists statements to test for the proper folder and file and then take action. Regardless of whether you are dealing with both OS's or not I would use the file and folder exists statements just in case you're dealing with machines that don't have PowerPoint on them as setting objects when something doesn't exist can cause errors. Here's some sample code that may help you out (Note that I didn't test this).

dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FolderExists("C:\Program Files (x86)\Microsoft Office\Office14")) Then
If filesys.FileExists("C:\Program Files (x86)\Microsoft Office\Office14\Powerpnt.exe")) Then
' Pin to start menu code goes here
end if
ElseIf filesys.FolderExists("C:\Program Files)\Microsoft Office\Office14")) Then
If filesys.FileExists("C:\Program Files\Microsoft Office\Office14\Powerpnt.exe")) Then
' Pin to start menu code goes here
end if
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top