I have a script that queries the Win7 Eventlog and outputs the results to a file. I then want to use the "Upload a File" KScript functionality to get that file onto the K1000.

The problem is that the KScript proceeds past the file generating step, and then tries to upload the file that isn't there yet. Has anyone successfully pulled something like this off?

It would be nice if there was a "wait some number of seconds" step we could put in the KScript. It just seems to launch everything at the same time, which is frustrating. 

UPDATE:
I got it working (sorta) by switching to an online shell script. This calls Powershell -command with the powershell commands I want to run, and then once it finishes I have it set to upload the file. This seems to work well, but I still haven't figured out how to get it to work with KScript. 

0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

2

Instead of uploading the file could you create a custom inventory rule to read it? 

ShellCommandTextReturn(cmd.exe /c type c:\programdata\dell\kace\event_4319_4321.log.txt )
Answered 05/31/2012 by: dugullett
Red Belt

Please log in to comment

Answers

0

What steps is your script taking? Are you uploading the file at "remediation success"? 

Answered 05/25/2012 by: dugullett
Red Belt

  • Wherever I put it, the script doesn't move slow enough to allow for the file to be generated.
  • How are you exporting the file from the script? Can you post a snippet? There's a few ways to do it.
  • Powershell -nologo -noprofile -windowstyle hidden -command "& {(get-date).tostring() | out-file $env:programdata\dell\kace\event_4319_4321.log.txt ; get-eventlog system |? {$_eventid -eq 4319 -or $_.eventid -eq 4321 -or $_.eventid -eq 1002 -or $_.eventid -eq 4199 -or $_.eventid -eq 8003} | Format-List TimeWritten,EventID,Message | out-file $env:programdata\dell\kace\event_4319_4321.log.txt -append}"
  • Any reason you are doing it with the "-command" instead of creating a ".ps1"? I'm not too familiar with doing it that way. Maybe Kace is seeing that Powershell.exe successfully ran and continued?
  • This content is currently hidden from public view.
    Reason: Removed by user request
    For more information, visit our FAQ's.
  • Powershell -nologo -noprofile -windowstyle hidden -command "& {(get-date).tostring() | out-file $env:programdata\dell\kace\event_4319_4321.log.txt ; get-eventlog system |? {$_eventid -eq 4319 -or $_.eventid -eq 4321 -or $_.eventid -eq 1002 -or $_.eventid -eq 4199 -or $_.eventid -eq 8003} | Format-List TimeWritten,EventID,Message | out-file $env:programdata\dell\kace\event_4319_4321.log.txt -append} start-sleep -seconds 15"
  • I have had trouble getting it to run silently with the -file method.
  • the KScript doesn't seem to wait to see if a execution of wscript completes or not. It will kick off wscript, which kicks off batch and moves on to the next step while the batch is running.
Please log in to comment
0

You could also just make the upload portion Task 2 in your script and Task 1 does the script run and file generation. The with Task 2 you can verify the file was created before it uploaded it. 

Answered 05/25/2012 by: nshah
Red Belt

  • I tried that, it will get to Task 2 and fail because the first task was still running, and hadn't generated the file yet.
Please log in to comment
0

You could try using a "delay" at the end of your script (after the file gets created) - for example, add "ping loopback -n 60" at the end of the script to add a pause (make the number larger or smaller as you see fit).  This should provide a buffer and allow the file to settle before the upload is attempted.

If that command isn't an option, you could see if something from here might be useful:

http://www.robvanderwoude.com/wait.php

John

Answered 05/25/2012 by: jverbosk
Red Belt

  • Any attempt I have made using a Sleep or Pause script has failed as the KScript will kick off the Sleep script, which will run, and sleep, but it doesn't wait for execution to end. It immediately continues down the list.
Please log in to comment
0

If you are using a K2000 also you have a file on your boot environments Kace has provided for this.  Ksleep.exe usage ksleep xx where xx is the seconds to sleep.

Answered 05/25/2012 by: SMal.tmcc
Red Belt

Please log in to comment
0

You can try creating a separate task to verify the file exists before uploading it, then remediate by sleeping, then uploading.

If that doesn't work, you can create a separate script entirely where you verify the file exists, upload it, and delete it if necessary.

I would get support involved, since it sounds like something people commonly want to do that isn't functioning as expected.

Answered 05/29/2012 by: philologist
Red Belt

Please log in to comment
0

Another idea - if pause scripts aren't working (and I see the same thing on the K2000 from time to time during scripted installs), you might try using a very simple compiled AutoIT script that runs a sleep command like this:

sleep(1000)

And use "run a program" (with the AutoIT compiled script - an EXE) as one of the steps.  Would be quick to setup and test, if nothing else.

John

Answered 06/08/2012 by: jverbosk
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share