/build/static/layout/Breadcrumb_cap_w.png

How to Leave "Directory" empty or null in online KScript?

As a step in one of my online KScripts, I need to copy a file. Since the "Launch a program" feature requires a "Directory:" if my "File" is set to "copy", the end result turns out to be something like "\copy source destination".  I suspect "copy" is built into the command shell (like it was in the old days of command.com), and not in a directory. How can I get the online KScript to leave the "Directory:" part of the path empty, so the end result is like "copy source destination"?


I could use "xcopy.exe", but I shouldn't have to.


Thanks!


/Kent



0 Comments   [ + ] Show comments

Answers (2)

Posted by: Nico_K 5 years ago
Red Belt
1

you cannot leave it empty.
The interpreter needs to know where to find the program (copy) you want to run.

Can you please provide what the script should do, since if you simply want to have a file on a special location there are other ways (Distribution | File Syncronization) to do it.


Comments:
  • But if "copy" is built into the interpreter, there is no "where" on the filesystem for the program to be found.

    And so I tried [\windows\system32\]"xcopy.exe", but I keep getting "not found", just as I did when I tried to run "%windir%\system32\curl.exe" (as documented in another question, and which you answered by suggesting I use "%windir%\sysnative", which worked, but which does not seem to work for "xcopy.exe").

    What I'm trying to do is write a script that uses curl to download the latest Firefox, and then install it, and then copy some configuration files (to set homepage, etc). Because of your help with the curl.exe issue, the script all works, except for the copying of the config files.

    File synchronization might work, if I can kick off the synchronization from the script, which I don't believe is possible. It seems to me that a Kscript (or even a batch file, which from the Kscript also fails to copy or xcopy these files) should be able to do something as simple as copy a file. I'm coming to the conclusion that it can't.

    As mentioned above, in the online KScript, I've tried two methods to copy these files:

    1) "Launch a program"
    Launch “%windir%\sysnative\xcopy.exe” with params “c:\windows\bootstat.dat c:\users\acutech\desktop”.

    (This is not the actual command[s] I started with; it's just a test to see if I can copy *any* file to a specific location; it fails.)

    2) "Run a batch file..."
    @echo off

    copy ”$(KACE_DEPENDENCY_DIR\autoconfig.js“ ”C:\Program Files\Mozilla Firefox\defaults\pref\autoconfig.js“
    copy ”$(KACE_DEPENDENCY_DIR\Mozilla.cfg“ ”C:\Program Files\Mozilla Firefox\mozilla.cfg“
    copy ”$(KACE_DEPENDENCY_DIR\override.ini“ ”C:\Program Files\Mozilla Firefox\browser\override.ini“
    copy c:\windows\bootstat.dat c:\users\acutech\Desktop

    (The last line is just a test to eliminate the reliance on the KACE_DEPENDENCY_DIR variable, in case it's not available in a batch file, and to try a different copy command, and different locations. No files get copied.) - kentwest 5 years ago
    • Whoa! Progress!

      I just added a line to my batch file, so that now it is:

      @echo off
      copy ”$(KACE_DEPENDENCY_DIR\autoconfig.js“ ”C:\Program Files\Mozilla Firefox\defaults\pref\autoconfig.js“
      copy ”$(KACE_DEPENDENCY_DIR\Mozilla.cfg“ ”C:\Program Files\Mozilla Firefox\mozilla.cfg“
      copy ”$(KACE_DEPENDENCY_DIR\override.ini“ ”C:\Program Files\Mozilla Firefox\browser\override.ini“
      copy c:\windows\win.ini c:\users\acutech\Desktop
      copy c:\windows\bootstat.dat c:\acutech\westz\Desktop

      The "win.ini" file does get copied; the bootstat.dat does not. Nor do the three I'm actually trying to copy.

      Conclusion concerning the batch file method:

      1) KACE variables are not available in batch files; I'll have to hard code those paths. No biggie, but the interface should really make that clear.

      2) The "copy" command does work from batch files in online KScripts, but only on certain files. I don't know what the magic is for determining which files can be copied and which can't. - kentwest 5 years ago
      • bootstat.dat is a locked system file so you cannot copy it with the copy command - SMal.tmcc 5 years ago
    • Apologies, Niko_K, for confusing you with Nick the Ninja and with SMal.tmcc; on most of these posts, the author is above the post to the left, and I just glanced in that location and thought the author of both comments was "Nick the Ninja". - kentwest 5 years ago
Posted by: SMal.tmcc 5 years ago
Red Belt
1

To your reply about "copy" not working:

The copy command shells when it runs and does not understand the $(KACE_DEPENDENCY_DIR variable.  what you need to do is hard path that copy. 

look at your script in the list mode and note the number at the bottom of the screen for it.

so instead of copy ”$(KACE_DEPENDENCY_DIR\autoconfig.js“ you would use copy "C:\ProgramData\Quest\KACE\kbots_cache\packages\kbots\528\autoconfig.js“


Note: if you copy a script with a hardcoded path in the tasks you must get the new id of the copied script and update the tasks.



Comments:
  • Thanks for your explanation SMAL.tmcc. About the bootstat.dat file, I just looked for a small text-looking file to test with, and I just randomly picked one that is a locked system file. Pfft.

    About the variable in the batch file, I suspected that might be the case when I wrote the batch as I did, but figured that'd make a good test of that idea, too, for future use. The "bootstat.dat" copy was supposed to serve as a control for that part of the test, but pfft, I randomly picked the wrong file to try to copy.

    Still, my preference would be to not use a batch file; I'm disappointed (and surprised) that simply copying a file via an online KScript is taking three days for me to figure out (and I still haven't figured it out). (Of course, I'm not spending 100% of my time on the task.) - kentwest 5 years ago
    • Another trick I found to copy the files from the kace directories is to:
      zip the files
      then call cmd with prams /c move $(KACE_DEPENDENCY_DIR)\file destination - SMal.tmcc 5 years ago
      • This suggestion sent me off on another possible line of attack, which didn't work, but eventually led me back to trying "xcopy" again, and once I got all my i's dotted and my t's crossed and my quotemarks singled or doubled and split and matched, I got a working copy command:

        Launch “%windir%\system32\xcopy.exe” with params “/y ”$(KACE_DEPENDENCY_DIR)\autoconfig.js“ ”C:\Program Files\Mozilla Firefox\defaults\pref“”.

        *Way* harder than it should've been.

        Thanks for your help, and especially for teaching this old dog the new trick about "sysnative". - kentwest 5 years ago
 
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