|
|
|||||||
Hi, Well this one has me stumped! Despite searching this board and experimenting left, right and centre. I have small piece of code which is supposed to run the MS UpTime utility and redirect the output to a txt file. The code works fine when I run from a command prompt. However when I schedule the script through task scheduler (running as admin) the output file still appears, but contains the script execution line rather than the Output of the uptime utility. Anyone have ideas why it might do that? Any help much appreciated! code:Many thanks,; *** Quarterly script to run "Uptime" comand *** |
||||||||
|
|
|||||||
break on $fl="c:\data\scripts\UptimeReport.txt" $cm='uptime /s /d:'+(@monthno-1)+'/01/'+@year+' \\@wksta >'+$fl ? $cm shell "%comspec% /c $cm" quote: [ 23. October 2002, 17:26: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Hi Howard, Thanks for the quick reply. Didnt make any difference Im afraid, from a command prompt the old and amneded versions work fine. However from a scheduled task the output file contains only one line: C:\KixScripts>wkix32 c:\kixscripts\uptime.kix Instead of the UpTime output. Any ideas? |
||||||||
|
|
|||||||
Mark... What OS? What Task Scheduler? |
||||||||
|
|
|||||||
In your script you reference what I assume is a mapped drive (F:) but I don't see you mapping it. |
||||||||
|
|
|||||||
Mapped drives are only available to a user account in the Task Scheduler if that user account established the mapping. Mappings created by other users are not available. You might be better off using UNC names. [ 23. October 2002, 18:46: Message edited by: sealeopard ] |
||||||||
|
|
|||||||
Hi... OS is Win2k SP3, F is not a mapped drive, its a seperate RAID drive. The task is running as an administrator and executes the command "kix32 c:\kixscripts\uptime.kix". I've also tried wkix32 as well. Any other info I can provide that might help? Thanks, |
||||||||
|
|
|||||||
Maybe you might want to try using WSHPIPE and WriteLog2() to generate your file. See http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=1;t=006044 for sample code. {edit} I once had a problem with redirection from a scheduled task. I think it dealt with a space or maybe the lack of a space between the last command line parameter and the ">" symbol. You my want to attempt your code again without the space that preceeds the ">". [ 23. October 2002, 19:24: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
I tested Howard's version as a Scheduled Task and it works like a charm. |
||||||||
|
|
|||||||
Hi... Thanks Howard... I tried taking the space out... the script still worked from the command line but is still producing the wrong output when scheduled. LLigetfa, Are you trying that on Win2k SP3? Many thanks, |
||||||||
|
|
|||||||
Mark, you can save yourself a lot of aggravation and time if you explore the WSHPIPE() and Writelog2() UDF solution mentioned above. This removes the need to use redirection at all. It even provides you an opportunity to edit/format the output you store in the file. [ 23. October 2002, 19:47: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Yes, Win2k, SP3, KiX 4.02 in %windir%, Uptime.exe in "C:\Program Files\Resource Pro Kit", using a domain admin account. |
||||||||
|
|
|||||||
Hi, Well its working... but the fix was bizarre in the extreme... The directory where my script is stored also had a batch file in which contained "wkix32 c:\kixscripts\uptime.kix". I stopped using it almost as soon as I created the task as I realised I might as well call the KIX script directly. Whilst experimenting just now I changed my task execution line from wkix32 to kix32. Then noticed that my broken output file still contained "wkix32 ... etc". At that point I realised the BAT file might be playing a part and deleted it... hey presto.. with no other changes than deleting the BAT file it now works... VERY strange... But thanks for all of your help... much appreciated! |
||||||||
|
|
|||||||
Well, Mark, now there's no doubt that you were going batty... |
||||||||
|
|
|||||||
Tell me about it! Now if I can just fix the nightmare that is "Win XP Service Pack 1"... I stand just a small chance of getting back my sanity... Perhaps... Thanks! |
||||||||
|
|
|||||||
I think our pal Einstein said it all... quote: |