|
|
|||||||
hello again... I am having some trouble getting a task created with the ScheduleTask UDF to run correctly. I noticed from some previous posts that the task gets run in the background if a different account is specified for it to run under. But I never see any sign of the task ever running (example...reg keys that should be added are not there). Below is the batch file that is calling a .kix file. I know its not a problem with either of the scripts since when I change the task to run as myself (the user logged on) so that it doesnt run it the background...It runs fine. If I change it to run as a different user then it doesnt run. The user I am changing it to has domain admin rights so I know it isnt a security issue. Anyone have any ideas? I can post the .kix script as well is necessary. Code: @echo off |
||||||||
|
|
|||||||
The use of %LOGONSERVER% requires a domain account to be used for the Task Scheduler. How do you provide the parameters to the ScheduleTask UDF? Please post the relevant code. |
||||||||
|
|
|||||||
This is the code I am using to schedule the task...The task seems to get created correctly (error 0). I can see the task on the remote machine. But when I log off or even if I right-click the task and select Run it seems to do nothing. If I edit the properties of the task and change it to my login and try running it again it seems to work. Code: Break On |
||||||||
|
|
|||||||
Maybe this is a false assumption...But when you run the task that points to a .bat as an admin account...The admin priviledges do get passed to other scripts that are launched from the .bat right? |
||||||||
|
|
|||||||
I also tried changing the password for the account I am using thinking maybe it was kind of password length restriction or something...No cigar. I changed it to the same as my account, which works. |
||||||||
|
|
|||||||
Couple of things. Try to manually schedule the task. Try to have the batch file on the local computer. The batch file can then still call the patch install routine on the server. Do a simple batch file that just does a NET SEND to you to test the scheduling. I've never used the ATLOGON indicator, try removing it and just do the NOW as it might conflict with each other. |
||||||||
|
|
|||||||
If it helps any...I get the same behavior if I go through the Windows GUI and creat the task manually. If I use a different account it doesnt do anything. As soon as I change it to the logged in account it works. Seems like more of a windows / task scheduler problem than a kix. |
||||||||
|
|
|||||||
ah-ha...Put the net send in the .bat and do indeed get a message when I run the task. So for some reason the .bat isnt able to start the .kix script. The .bat is pretty simple... Code: @echo off Also added the following line to the beginning of the .kix script that is called from the .bat. But I never see this second message. Code: shell '%comspec% /c net send testcomputer The Scheduled Kix Script Has Begun' |
||||||||
|
|
|||||||
Also get the same result if the .bat script is copied to local drive. |
||||||||
|
|
|||||||
Then I'd say the %LOGONSERVER% is not getting translated correctly. Put a Code:
into the batch file. That'll show you to what the environmentvariable gets translated to. BTW, the %LOGONSERVER% will get translated to the server that authenticates the account used to run the scheduled task. |
||||||||
|
|
|||||||
echo "%LOGONSERVER%" >F:\ts_echo.txt results in a text file containing only the "" I had to change it from %temp% to F:\ because apparently the %temp% isnt getting defined either. Do you have any idea what would cause this? |
||||||||
|
|
|||||||
Not so sure the %logonserver% is going to be possible when using a scheduled task. I was wrong about the %temp% not getting set...It was set just to the other accounts profile. A number of env variable get set...When I do a set > F:\variables.txt I get... Quote: As you can see...No logonserver. I also tried passing the %logonserver% as a variable to the first .bat. Task Scheduler wont expand it out...The variable is literally "%logonserver" in the .bat. This sucks... |
||||||||
|
|
|||||||
I've found some stuff on the Windows & .NET Magazine website which essentially states that user environment variables are not available in scheduled tasks. Thus, both %LOGONSERVER% and %TEMP% would fail. Systemwise environment variables should be available. %TEMP% might be available and point to the system temp directory. A way around this might be to schedule a task that calls %COMSPEC% with a parameter indicating the batch file. This might trigger the initialization of the user environment variables. Okay, found another reference in a newsgroups, see Environment Variable in Schedule Task . So, essentially, don't use user environment variables. I'll put a disclaimer into the UDF to reflect this. |
||||||||
|
|
|||||||
That blows...Oh well. Have yet to find a way to get the %logonserver%. How accurate is the @LServer macro on NT4/2K/XP clients? Workaround I am going with for now. Copied the msupdater_install.kix script to same share that the .bat was previously located. Renamed the .kix file to kixtart.kix and also copied in wkix32.exe. This way I can set the task to run \\server\share\wkix32.exe. This launches the main isntall script and then refers to the @LServer everywhere I used to use %logonserver%. The only problem is that now the script and wkix32.exe is coming from a share here over the WAN everytime a user runs it (about 260kb). I will do some testing over a slow link and see if it causes any issues. |
||||||||
|
|
|||||||
Thanks for all of the help by the way...I never would have never thought that the %logonserver% wasnt being defined. |
||||||||
|
|
|||||||
@LSERVER might not be available either but it should be easy to test this. |
||||||||
|
|
|||||||
@LServer seems to work. Do you schedule tasks across your WAN? How do you do it without the updates having to go across the WAN whenever an update is run? Especially is it is scheuled in the middle of night when noone is logged on. Im guessing then @LServer wouldnt be available. Would @IPAddress0? Maybe I can make an .ini with all the locations listed and which server to use depending on their IP. |
||||||||
|
|
|||||||
I just have a LAN with 100MBit to desktops and 1GBit to servers fully switched with one central admin share for updates/installs. I normally run updates/installs during the night as we keep our computers running 24/7 due to number-crunching routines run on various machines. @LSERVER and @IPADDRESS0 should be available in the client script as it does run under a user's context. @LSERVER should contain the server that authenticated the user when the scheduled task was started. |