Copying a file using directory variables %folder%
I'm trying to run a batch file via the Scripting module that copies and overwrites a file. The line I'm using is...
start /wait xcopy \\server2\public\av\SignageServerSettings.xml %fwi%\SignageSettings\ /y
If I just run the batch file on the workstation, it works fine. But when I try to push it out via the KBox, it doesn't recognize the %fwi% variable and just copies to the root of the C:\ drive.
Any ideas?
Thanks.
Answers (4)
I am using an Online Shell Script and I tried selecting "Run as Local System" and "Run as User logged in to console" which did not work. Finally I ran it and provided the Domain admin credentials. This seemed to work. I also had to enclose the source and destination paths in " " incase there were any spaces in the path.
Dump the batch file and use robocopy.exe in your script
http://technet.microsoft.com/en-us/library/cc733145(v=ws.10).aspx
Comments:
-
Just saw your answer here. I'll try this if my fix doesn't work. Thanks. - bruno71 12 years ago
-
Robocopy does not seem to exist on Windows XP. The workstations I'm doing this on are a mix of XP and 7. - bruno71 12 years ago
-
Sorry for that oversite when I replied. No it is not by default but you can download and add it, (pain for this one)
http://theos.in/windows-server/free-download-windows-xp-2003-robocopy-software/ - SMal.tmcc 12 years ago
It's an environment variable created by a third-party program we use. It exists and works in Windows Explorer or by manually running the batch file. But when I try to push the same batch file out via KBox, it does not seem to recognize it.
Example:
%fwi% points to "C:\Documents & Settings\All Users\Documents\Four Winds Interactive\"
But when I push out the batch file with KBox, instead of the xcopy destination being...
"C:\Documents & Settings\All Users\Documents\Four Winds Interactive\SignageSettings\"
...it copies the file to "\SignageSetings\" and it ends up creating a folder at "C:\SignageSettings\"
Comments:
-
I'd be curious if %fwi% works as System instead of a user. Try running the batch using PsExec: http://www.kace.com/support/resources/kb/article/how-to-mimic-running-a-script-as-local-system-user-scripting
If not, use an online script and use a different account. - jknox 12 years ago