Answered by:
Logon Script not running as a user

Question
-
I have a couple of machines running windows 7 and a few with windows vista. They are hooked to a server 2003 dc with a vbs logon script assigned via gpo. the script is run by the launchapp.wsf script. They will only run when the user is added to the Administrators group. GPO still runs but the script will not. The script is a very simple one that will map drives. It will run correctly only if the user has admin rights. I checked the directory where the script is saved and domain users and even everyone has read access. Any ideas?Saturday, December 5, 2009 2:38 AM
Answers
-
Hi,
I would like to suggest you try GP Preferences to map a drive on clients:
GP Preferences Will Reduce Logon Scripts : Mapping Drives
Using Group Policy Preferences to Map Drives Based on Group Membership
Hope this helps. Thanks.
Nicholas Li - MSFT- Marked as answer by Nicholas Li Wednesday, December 16, 2009 6:51 AM
Friday, December 11, 2009 10:59 AM -
Hi
Please refer to:
Group Policy Preferences: Getting Started
Group Policy Preferences Overview
Thanks.
Nicholas Li - MSFT- Marked as answer by Nicholas Li Wednesday, December 16, 2009 6:51 AM
Monday, December 14, 2009 8:30 AM
All replies
-
I have a couple of machines running windows 7 and a few with windows vista. They are hooked to a server 2003 dc with a vbs logon script assigned via gpo. the script is run by the launchapp.wsf script. They will only run when the user is added to the Administrators group. GPO still runs but the script will not. The script is a very simple one that will map drives. It will run correctly only if the user has admin rights. I checked the directory where the script is saved and domain users and even everyone has read access. Any ideas?
Us this kind of validation into your script
ATTRIB %windir%\system32 -h | FINDSTR /I "denied" >nul
IF NOT ERRORLEVEL 1 (
--- This script won't run
goto end
)
END-- This will run only if you have admin rights.
Best regards and excuse me for my bad english...
Ricardo Polo "HodracirK"Saturday, December 5, 2009 4:15 PM -
So will this only allow the script to run if the use is an admin? It currently works fine if the user has admin rights. I need it to run under a normal user account.Saturday, December 5, 2009 5:53 PM
-
So will this only allow the script to run if the use is an admin? It currently works fine if the user has admin rights. I need it to run under a normal user account.
Now I understand...
please tell me what your script does.. maybe you can copy it here
Ricardo Polo "HodracirK"Saturday, December 5, 2009 9:55 PM -
Ok, here are the scripts... since it is win7 and vista in the environment I used the launchapp script to launch the logon script as a task.... both are below...
launchapp is ran from user gpo with logon.vbs as a parameter.... thanks for the help!
launchapp.wsf
<job><script language="VBScript">
'---------------------------------------------------------
' This sample launches the application as interactive user.
'---------------------------------------------------------
' A constant that specifies a registration trigger.
const TriggerTypeRegistration = 7
' A constant that specifies an executable action.
const ActionTypeExecutable = 0
' A constant that specifies the flag in RegisterTaskDefinition.
const FlagTaskCreate = 2
' A constant that specifies an executable action.
const LogonTypeInteractive = 3
If WScript.Arguments.Length <> 1 Then
WScript.Echo "Usage: cscript launchapp.wsf <AppPath>"
WScript.Quit
End If
strAppPath = WScript.Arguments(0)
'********************************************************
' Create the TaskService object.
'********************************************************
Set service = CreateObject("Schedule.Service")
call service.Connect()
strTaskName = "Launch App As Interactive User"
'********************************************************
' Get a folder to create a task definition in.
'********************************************************
Dim rootFolder
Set rootFolder = service.GetFolder("\")
'Delete the task if already present
On Error Resume Next
call rootFolder.DeleteTask(strTaskName, 0)
Err.Clear
'********************************************************
' Create the new task
'********************************************************
Dim taskDefinition
Set taskDefinition = service.NewTask(0)
'********************************************************
' Create a registration trigger.
'********************************************************
Dim triggers
Set triggers = taskDefinition.Triggers
Dim trigger
Set trigger = triggers.Create(TriggerTypeRegistration)
'***********************************************************
' Create the action for the task to execute.
'***********************************************************
' Add an action to the task. The action executes the app.
Dim Action
Set Action = taskDefinition.Actions.Create( ActionTypeExecutable )
Action.Path = strAppPath
WScript.Echo "Task definition created. About to submit the task..."
'***********************************************************
' Register (create) the task.
'***********************************************************
call rootFolder.RegisterTaskDefinition( _
strTaskName, taskDefinition, FlagTaskCreate, _
,, LogonTypeInteractive)
WScript.Echo "Task submitted."
</script>
</job>
logon.vbs
On Error Resume NextSet objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CNSelect Case strGroupName
Case "Media Users"
objNetwork.MapNetworkDrive "z:", "\\server\media"
Case "Administrators"
objNetwork.MapNetworkDrive "X:", "\\server\admin"
End Select
Next- Proposed as answer by Eduardo Menegalli Nazato Tuesday, April 27, 2010 2:40 PM
Friday, December 11, 2009 5:20 AM -
Hi,
I would like to suggest you try GP Preferences to map a drive on clients:
GP Preferences Will Reduce Logon Scripts : Mapping Drives
Using Group Policy Preferences to Map Drives Based on Group Membership
Hope this helps. Thanks.
Nicholas Li - MSFT- Marked as answer by Nicholas Li Wednesday, December 16, 2009 6:51 AM
Friday, December 11, 2009 10:59 AM -
I would like to, is it possible to run on server 2003?Friday, December 11, 2009 10:23 PM
-
Hi
Please refer to:
Group Policy Preferences: Getting Started
Group Policy Preferences Overview
Thanks.
Nicholas Li - MSFT- Marked as answer by Nicholas Li Wednesday, December 16, 2009 6:51 AM
Monday, December 14, 2009 8:30 AM -
Nicholas, are you some kind of automate to redirect to WRONG solutions? This does not apply to 2003 server. Replying "NO" to me1234567689 's last question is much faster than pasting your links fourth time.
Let me guess the your next post here, Nicholas: "Hi , Please refer to:..."
Thursday, January 28, 2010 1:04 PM -
Tuesday, April 27, 2010 2:40 PM