Page 1 of 1 1
Topic Options
#205901 - 2012-10-04 08:26 PM Question about Syntax
schwarzchr Offline
Just in Town

Registered: 2009-08-05
Posts: 4
Loc: Germany
Hi,

if a file in a folder exists i want to copy all files from an folder
to another folder. In the folder where i want to copy from the Username ist part of
the foldername.

Is this the right syntax ?
 Code:
$Desktop_Loc = '%USERPROFILE%\Desktop

IF EXIST "\\serv01\home\"+@USERID+"\windows\migration.txt" - homedrive of the user
IF EXIST "\\serv01\e$\anwprofl\tsp_"+@USERID+"" - profile-path of the user
copy "\\serv01\e$\anwprofl\tsp_"+@USERID+"\*.*" "$Desktop_Loc\*.*" /c /s
ENDIF
ENDIF

It would be nice, if you answer me, because i do not work all days with kix.

Kind Regards

Christian


Edited by Mart (2012-10-04 11:17 PM)
Edit Reason: Please use code tags when posting code.

Top
#205903 - 2012-10-04 11:16 PM Re: Question about Syntax [Re: schwarzchr]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Hi and welcome to the board.

A few things that pop up at first sight:

  • Please use code tags when posting code.
  • You need to match your quotes. Double or single quotes does not really matter as long as they are used in pairs.
  • Never include variables or macro’s in a string. They may not be resolved correctly.
  • The dollar character is a reserved character in kix so using it in a path might cause issues. NoVarsInStrings should take care of this.
  • Commenting lines can be done with the ; character and not the minus character.
  • Regular users will not have access to the admin share on any computer, \\server01\e$ in your script.
  • Personally I not care so much for the /c parameter in the copy command. It continues even if there are errors. I would like it to stop if there are errors and put in some error logging code so it is clear what is going wrong.


The code below is a bit cleaned up and at first sight looks like it should do the job but I did not test it.
 Code:
$rc = SetOption("NoVarsInStrings", "On")

$Desktop_Loc = ExpandEnvironmentVars(%USERPROFILE%)
$Desktop_Loc = $Desktop_Loc + "\Desktop"

If Exist ("\\serv01\home\" + @USERID + "\windows\migration.txt") ;homedrive of the user
	If Exist ("\\serv01\e$\anwprofl\tsp_" + @USERID) ; profile-path of the user
		Copy "\\serv01\e$\anwprofl\tsp_" + @USERID + "\*.*" $Desktop_Loc + "\" /c /s
	EndIf
EndIf


Edited by Mart (2012-10-08 12:21 PM)
Edit Reason: Corrected the code
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#205929 - 2012-10-08 10:24 AM Re: Question about Syntax [Re: Mart]
schwarzchr Offline
Just in Town

Registered: 2009-08-05
Posts: 4
Loc: Germany
Hi,

thanks for your help, but i get an error at command line 6
(If Exist "\\serv01\home\" + @USERID + "\windows\migration.txt"):
ERROR: invalid method/funktion call: missing'<'!
Script I:\test.kix
Line : 6

I have used the script in the thread before without e$.

Kind Regards
Christian

Top
#205931 - 2012-10-08 12:20 PM Re: Question about Syntax [Re: schwarzchr]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
The brackets are not placed correctly.
I corrected the code in my previous post.


Edited by Mart (2012-10-08 12:22 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 525 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.058 seconds in which 0.029 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org