theorist80 Posted September 26, 2008 Posted September 26, 2008 (edited) We are running 2 Vista machines in a Windows 2003 domain environment. We are having issues with the login scripts like everyone else. We think for our scenario that we might have it fixed but we cant seem to figure out this last part. We have the "launchapp.wsf" all created and working. In doing so, this script creates a new task in the task scheduler. This works perfect for admins but doesnt work at all for non-admins. Is it possible to VB into the launchapp.wsf file to tell the task scheduler that once this script has run, to DELETE the task from the scheduler? I don't want it to stop, i want it DELETED. Is there anyway to encode this?Here is the code:<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 ' A constant that specifies the flag in RegisterTaskDelection.const FlagTaskDelete = 2 If WScript.Arguments.Length <> 1 ThenWScript.Echo "Usage: cscript launchapp.wsf <AppPath>" WScript.QuitEnd IfstrAppPath = WScript.Arguments(0)'********************************************************' Create the TaskService object.'********************************************************Set WshNetwork = WScript.CreateObject("WScript.Network")Set service = CreateObject("Schedule.Service")call service.Connect()strTaskName = "Launch App As Interactive User for " & WshNetwork.UserName'********************************************************' Get a folder to create a task definition in. '********************************************************Dim rootFolderSet rootFolder = service.GetFolder("\")'Delete the task if already presentOn Error Resume Nextcall rootFolder.DeleteTask(strTaskName, 0)Err.Clear'********************************************************' Create the new task'********************************************************Dim taskDefinitionSet taskDefinition = service.NewTask(0) '********************************************************' Create a registration trigger.'********************************************************Dim triggersSet triggers = taskDefinition.TriggersDim triggerSet trigger = triggers.Create(TriggerTypeRegistration) '***********************************************************' Create the action for the task to execute.'***********************************************************' Add an action to the task. The action executes the app.Dim ActionSet Action = taskDefinition.Actions.Create( ActionTypeExecutable )Action.Path = strAppPathWScript.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> Edited September 26, 2008 by theorist80
theorist80 Posted September 26, 2008 Author Posted September 26, 2008 im guessing that its not possible?Even though I do think it is very weird that I can create and stop a task but I can't delete one...sucks cause I would really like that to work
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now