/build/static/layout/Breadcrumb_cap_w.png

KScript Timing: How to stagger the steps?

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

Answers (7)

Posted by: dugullett 11 years ago
Red Belt
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 )
Posted by: dugullett 11 years ago
Red Belt
0

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


Comments:
  • Wherever I put it, the script doesn't move slow enough to allow for the file to be generated. - muebel 11 years ago
  • How are you exporting the file from the script? Can you post a snippet? There's a few ways to do it. - dugullett 11 years ago
  • 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}" - muebel 11 years ago
  • 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? - dugullett 11 years ago
  • 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" - dugullett 11 years ago
  • I have had trouble getting it to run silently with the -file method. - muebel 11 years ago
  • 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. - muebel 11 years ago
Posted by: nshah 11 years ago
Red Belt
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. 


Comments:
  • 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. - muebel 11 years ago
Posted by: jverbosk 11 years ago
Red Belt
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


Comments:
  • 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. - muebel 11 years ago
Posted by: SMal.tmcc 11 years ago
Red Belt
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.

Posted by: philologist 11 years ago
Red Belt
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.

Posted by: jverbosk 11 years ago
Red Belt
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

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ