Retrieve Kace Dependency Dir during run-time of KScript?
I have a offline kscript that runs a batch file. I know that I can use token replacement variables to generalize things like the $(KACE_DEPENDENCY_DIR), but what about inside a batch file that the kscript runs? Is there some convenient way of doing this?
Simply adding $(KACE_DEPENDENCY_DIR) to the batch script doesn't seem to work.
(Pic Unrelated)
Answers (3)
Hardcoding the dependency dir is how I ended up doing that, although it makes me a bit squeamish. It would be nice to be able to abstract it.
I handle this problem another way: in a few "Run a batch file" script steps, I pass "$(KACE_DEPENDENCY_DIR)" in as the first parameterin the script, then use it as %1 in the batch file itself.
But there's another way to get it: the full pathname of every batch file is available to the batch file as %0.
Using the %~ tricks documented here:
http://ss64.com/nt/syntax-args.html
you can get just the drive and path parts of %0, or strip the quotes from %1.
For all batch file questions, I find that ss64.com site the very best reference. Sande
The $(KACE_DEPENDENCY_DIR) is a system variable on the K1K; you can't access it with the batch file deployed to the system. The way to do this is to log into the K1K as http://yourk1k/adminui rather than just admin. This will allow you to see the full URLs for each page. The unique number for each script, managed install, etc. will tell you what the number will be for the deployment folder, and you will be able to call out the correct dependency folder in your batch script.
Comments:
-
PS. There may not be electricity. To properly prepare for the Zombie Apocalypse, go here: http://www.cdc.gov/phpr/zombies.htm. - philologist 12 years ago
-
Hardcoding the dependency dir is how I ended up doing that, although it makes me a bit squeamish. It would be nice to be able to abstract it. - muebel 12 years ago
Under any script there is a Policy or Job Rules area. Next to that is a yellow box. Clicking on that will tell you the pathways each of the KBOX internal varilables use. As Philologist indicated, you will need to know the folder number the KBOX will create to point your batch file to the right location.