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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Logon Script - PATH

Status
Not open for further replies.

tekieVB

MIS
Apr 25, 2002
112
US
Does anyone know if it is possible to add an additional PATH to the existing PATH via the logon script?
 
Try this...

Code:
Option Explicit

Dim strComputer, strPath, strAdditionalPath
Dim objWMIService, objItem
Dim colItems

strComputer = "."
strAdditionalPath = "C:\"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_Environment Where Name = 'Path'")

For Each objItem in colItems
	strPath = objItem.VariableValue
	If InStr(strPath,";" & strAdditionalPath & ";") = 0 Then
		strPath = strPath & ";" & strAdditionalPath & ";"
		objItem.VariableValue = strPath
		objItem.Put_
	End If
Next

[URL unfurl="true"]http://www.microsoft.com/technet/scriptcenter/resources/qanda/mar05/hey0318.mspx[/url]

Good Luck!

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top