After looking over the script, I decided I would try to convert it for kix purposes. I had to add the ablility to accept arguments and a little error testing. It appears to run for me on my computer, but none of my clients use a GPO Script.
I was wondering if someone with a GPO Script could test it and post back their results. The point of the the function is to map drives and printers in the context of the user with the UAC on (Vista, Win7) while running in a GPO script. Just create a simple mapdrives.kix file to go along with this.
I would say yes... When I was working on this, I got the impression that you could pretty much set up any scheduled task with any user. However, that is not the point of THIS particular UDF.
If you can make it work, post your code and maybe we can work on the UDFs to make it a new UDF that takes both a user and program.
Interesting... that would have never crossed my mind as something to look out for... the bad news is, I'm not seeing anything obvious to fix it... here is msdn's page on this...
You want to talk about a needle in a hay stack... I found, count them, ONE page in my google searches with an example of how to use the SETTINGS, and it was in Chinese. Nothing on MSDN explaining how to use it.
The good news is, the top most post contains the updated function. See if it works any better.
KIXKicksKIXKicks
Starting to like KiXtart
Registered: 2002-07-26
Posts: 177
Loc: Vancouver, WA
Both...
I have a script which updates the GPO and a local folder on the user's computer when they log in. Alot of times they are remote and so they need their drives via VPN connection.
Thanks for letting me know you are using it. The working directory setting was added after I initially wrote this, and I see what you mean. I'll see what I can do to fix it.
Would you mind trying this and see if it takes care of the problem with workdir?
Code:
FunctionRunAsInteractiveUser($KixPath,optional$kixscript,optional$workdir,optional$taskname,optional$donotdelete)Dim$service,$rootfolder,$taskdefinition,$triggers,$trigger,$action,$settingsDim$TriggerTypeRegistration,$ActionTypeExectuable,$flagtaskcreate,$logontypeinteractiveif$taskname=""$taskname="Run As Interactive User - "+@ticksendif$TriggerTypeRegistration=7$ActionTypeExecutable=0$FlagTaskCreate=2$LogonTypeInteractive=3ifexist($KixPath)$service=CreateObject("Schedule.Service")$service.Connect()$rootFolder=$service.GetFolder("\")$rootFolder.DeleteTask($taskname,0)$taskDefinition=$service.NewTask(0)$triggers=$taskDefinition.Triggers$trigger=$triggers.Create($TriggerTypeRegistration)$settings=$taskDefinition.Settings$settings.DisallowStartIfOnBatteries=not1$settings.StopIfGoingOnBatteries=not1$Action=$taskDefinition.Actions.Create($ActionTypeExecutable)$Action.Path=$KixPathif$kixscriptif$exist($kixscript)$Action.Arguments='"'+$kixscript+'"'elseexit2endifendifif$workdirifexist($workdir)$action.WorkingDirectory='"'+$workdir+'"'elseexit2endifendif$rc=$rootFolder.RegisterTaskDefinition($taskname,$taskDefinition,$FlagTaskCreate,,,$LogonTypeInteractive)ifnot$donotdeletesleep1$rootFolder.DeleteTask($taskname,0)endifelseexit2endifendfunction
I was given the task to create my first logon script in the current millennium Your function works a treat, albeit Cuthbert from 3 posts above is right:
You have to provide a $workdir parameter for this to work
So, this one should be REQUIRED Care to post this in the udf lib?