Custom Inventory - ShellCommandTextReturn does not work
Ok, I have created some vbscripts to search for file types PST, MDB & XLA files which report back as a String, the file paths, names and sizes. The script works perfectly.
So I distrbuted the scripts using KACE Scripting feature and have the folder numbers used in the KBOX cache stored in the All User/ProgramData folders.
I have then added the Software with custom inventory rules as below:-
ShellCommandTextReturn(cscript.exe /nologo "C:\Documents and Settings\All Users\Dell\KACE\kbots_cache\packages\kbots\137\FindMDBFiles.vbs")
This DOES NOT WORK! The same command editing for Windows 7 profile structure works perferctly as below:-
ShellCommandTextReturn(cscript.exe /nologo "C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\137\FindMDBFiles.vbs")
The only difference is spaces in the folder structure.
Any ideas?
I understand that KACE cannot nest KBOX functions and also doesn't support Windows Environment Variables either.
Answers (2)
You have to escape the quotes with a backslash:
ShellCommandTextReturn(cscript.exe /nologo \"C:\Documents and Settings\All Users\Dell\KACE\kbots_cache\packages\kbots\137\FindMDBFiles.vbs\")
Support gave me this solution when I submitted a ticket for a similar issue.
Comments:
-
great stuff, I would have preferred to use the escape the quotes solution, would be nice if they documented this stuff!
Instead i created a ZIP file containing my scripts and used a scripting task to extract the zip file to C:\Windows\KACE.
I'll probably re-work this to use the escape quotes solution. - Geedoubleu 12 years ago -
Using Agent 5.3.53177 this doesn't work for me, in the debug log I also see it interpretting the "and" in "Documents and Settings" as a LOGICAL AND, so splits it into two rules... this is quite annoying. The workaround in the end by support was to use DOS 8 character representation for the path, so C:\Docume~1\AllUse~1\Dell\KACE\etc lets hope you never have to use a path with "OR" or "AND" in the first 6 characters of a folder name! - AJStevens 12 years ago
I can make this run on Windows XP by copying the vbscripts to C:\Windows\KACE and then it works perfectly.
The only conclusion I have is that the ShellCommandTextReturn(command) cannot handle spaces in the command and does not respect " " as you would normally use in Windows.
I've now got to work out how to copy these scripts to C:\Windows\KACE with-out flashing up a DOS prompt on everyones computers.
I've never known a product with so many un-documented nuances!