K1000,scripting and BAT files-listens like a toddler
Hello IT Ninjas-
This issue has been an ongoing situation since we deployed our KACE units a year ago. Scripting has been the occassional thorn in my department's collective side as it's like the K1000 picks and chooses when to do what it's told, do nothing or what now seems to be do SOME of the things. Here's the latest example that got me to jump onto the boards:
I needed to deploy a new URL shortcut to everyone in the company's desktop. However, a certain group of people have access and a separate shortcut to a more "advanced" version of this web site. This would be no problem-create a batch file that sniffs out the username and if the person who's logged in is on the list, skip to the end of the batch file. If not, clear out any shortcuts that would confuse the user and then copy in the proper one. Here's the batch file (with user names changed to protect the innocent with explanation):
[here's the user list. If the name matches the username, go to "end")
IF (%username%)==(fhtehd) goto end
IF (%username%)==(sdfhtjk) goto end
IF (%username%)==(dsfhrtej) goto end
IF (%username%)==(wsdetjsm) goto end
IF (%username%)==(drffhkk) goto end
IF (%username%)==(edhrtejsrtj) goto end
IF (%username%)==(dhjsfky) goto end
[there's more but you get the idea]
del "c:\documents and settings\all users\Desktop\Prod.url"
del "c:\documents and settings\all users\Desktop\Training Manuals.lnk"
del "z:\profiles\all users\Desktop\Prod.url"
del "z:\profiles\all users\Desktop\Training Manuals.lnk"
del "c:\users\public\desktop\Training Manuals.lnk"
del "z:\profiles\public\desktop\Training Manuals.lnk"
[these clear out the shortcuts in different locations and drives as some machines have Data Igloo installed]
copy "s:\Desktop Links\Employee Self Service.url" "c:\documents and settings\all users\Desktop\Employee Self Service.url"
copy "s:\Desktop Links\Employee Self Service.url" "z:\profiles\all users\Desktop\Employee Self Service.url"
copy "s:\Desktop Links\Employee Self Service.url" "c:\users\public\desktop\Employee Self Service.url"
copy "s:\Desktop Links\Employee Self Service.url" "z:\profiles\public\desktop\Employee Self Service.url"
Now if I ran this directly on any PC, it would function just right every single time. Now I set up an Online Script on the K1000. It's set to run as User logged in to console, the task Verify is set to "Always Fail" (as I was instructed ages ago to have a "better chance" of things working) and in Remediation I have it launch a bath file from the network (I've stopped creating a batch file within the task as most of the time it never, ever runs).
So when I run the script, it goes to the designated PC, runs and gets as far as the clearing of the old shortcuts but stops dead. No copying of the new shortcut. If I rearrange the two chunks of commands so it copies first THEN deletes, the copying happens but not the deleting. I've tried referencing the actual path of the "s:" drive, changing the "Run As" to from current user to system and then to a domain admin account with no difference. When I took the copying part out and created a separate batch file to run from a separate Script, THEN it worked.
So does anyone know what the deal is? Why is it when a batch file is run from the Kbox it seems to be a crap shoot if it works? Is there something I'm missing? It should just run the batch file as if the user themself ran it but yet it doesn't. Do I have to offer the Kbox a sucker for it to work?
Any help would be greatly appreciated. Thanks!
Community Chosen Answer
change the copy command to xcopy. Is the s drive already mapped?
For the script
create an online script, run as all logged in users,
upload your batch file as a dependancy.
for verify just use verify that the directory c:\windows exists.
launch a program
use $(KACE_DEPENDENCY_DIR) as the directory and your batch file as the program