This is how I do it. I am trying to figure out if I am missing something that would make this process less annoying, but here it is:

  1. Create new offline KScript
  2. Attach all the dependencies I am going to need.
  3. One of these dependencies is "invis.vbs" which just takes in a batch file and executes it.
  4. Create a task which executes the program %systemroot%\system32\wscript.exe with parameters $(KACE_DEPENDENCY_DIR)\invis.vbs  $(KACE_DEPENDENCY_DIR)\BATCH_FILE.bat
Now all of the above is set up as such simply so I can run a batch file invisibly, with no possiblity of interaction with the user.
 
In that batch file, if I want to interact with any of the dependencies, I have to CD to the depedency directory, that is C:\programdata\dell\kace\kbots_cache\packages\kbots\<SCRIPT NUMBER>

This makes the script essentially only usable when run by the kagent, and also that I have to create the kscript before I can figure out what the number is going to be.
 
If I want to make use of powershell, I have to include the powershell commands via batch like this:
powershell -command "& {gwmi win32_product |? {$_.name -match 'Adobe Reader'}}"
 
I haven't figured out how to run powershell scripts silently.

How do you push scripts invisibly? There has to be a more elegant way...
1 Comment   [ + ] Show Comment

Comments

  • %~dp0 resolves to the full path leading up to the script. I.E. the working directory that the script was run from.

    I now use this method in order to ensure the script knows where it's dependencies are.
Please log in to comment

Community Chosen Answer

4

Are you referring to the CMD prompt that pops up for a few seconds? I've had success using http://www.f2ko.de/programs.php?lang=en&pid=b2e I first create a .bat with something like this:

@echo off

powershell.exe -nologo -executionpolicy bypass -noprofile -file script.ps1

Then using the converter I include my .ps1 file. This will compile the powershell script as an exe and it will deploy silently.

 

I've also used shell scripts to deploy Powershell. Just upload the .ps1 as a dependency and add this. Make sure to change to script.bat at the bottom. (Still displays the CMD prompt for a couple of seconds)

Answered 09/11/2012 by: dugullett
Red Belt

  • So the actual answer is:-

    THE K1000 CANNOT RUN VBSCRIPT OR POWERSHELL SCRIPTS WITHOUT A BLACK CMD BOX POPPING UP FOR AT LEAST A FEW SECONDS.

    This is because the K1000 agent does not support windows scripting or powershell requiring you to run cscript.exe or powershell.exe programs in cmd windows or BAT file.

    I'd love someone to show me how, other than use software to convert scripts into executable program files.
  • I use wscript.exe to run the invis.vbs script silently
  • This content is currently hidden from public view.
    Reason: Removed by member request
    For more information, visit our FAQ's.
Please log in to comment

Answers

1

Another option would be to attach the batch (outside of the .vbs) as a dependency and use the "Launch a program" feature calling "file.bat" for example.

That should not pop up the batch window.

Answered 09/11/2012 by: jknox
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity