Page 1 of 1 1
Topic Options
#62779 - 2002-02-04 07:23 PM IF Statement
Phil Q Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 18
Loc: UK
I have written this script to check if OS is Win 9x and copy a file to a specified location and if not copy the file to another location. This does not work so please let me as I am new to Kixstat.
==use s: ("\\triton.part\shared")
use u: ("\\triton.part\users")
use Z: ("\\Avmanage\programs")

IF EXIST
c:\windows
copy z:\lmhost c:\windows
else
copy z:\lmhost c:\winnt\system32\drivers\etc

ENDIF

Thanks

Top
#62780 - 2002-02-04 07:26 PM Re: IF Statement
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
exist syntax is the one that ain't right here.

try:
if exist("c:\windows")

cheers,

_________________________
!

download KiXnet

Top
#62781 - 2002-02-04 07:35 PM Re: IF Statement
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Phil Q,

Welcome to the board..

Have you looked into the following macros:

quote:

@INWIN Operating system: 1 = Windows NT; 2 = Windows 9x

Or...

quote:

@DOS Version of Windows NT

Thanks!

- Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#62782 - 2002-02-04 07:56 PM Re: IF Statement
Phil Q Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 18
Loc: UK
Lonkero
The script is not giving me any errors but the file is not being copied. Any ideas?

Thanks anyway...

Top
#62783 - 2002-02-04 08:08 PM Re: IF Statement
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
phil, can't see why you don't get errors.
the syntax is wrong so it should give one.
anyway, you can't copy directories with kix-copy.
here is what it does:
quote:
COPY
Action
Copies one or more files.

Syntax
COPY "source" "destination" [/h]

Remarks
Wildcards are supported.
If a file already exists at the destination, it is overwritten without warning.
The /h option can be used to include files with the hidden or system attribute set in the copy.


so to copy all files in the directory try this one:

code:

IF EXIST("c:\windows")
copy "z:\lmhost\*.*" "c:\windows\" /h
else
copy "z:\lmhost\*.*" "c:\winnt\system32\drivers\etc\" /h
ENDIF

kdyer pointed out good issue.
if you are checking c:\windows it may not be allways right.
nt-machines can also have c:\windows as root directory.
%windir% is the place where windows resides.
to check different os inwin is good one.
so you might also want to try this one:

code:

IF "@inwin"="2"
copy "z:\lmhost\*.*" "%windir%" /h
else
copy "z:\lmhost\*.*" "%windir%\system32\drivers\etc\" /h
ENDIF

cheers,

_________________________
!

download KiXnet

Top
#62784 - 2002-02-04 08:23 PM Re: IF Statement
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Jooel,
I believe LMHOSTS to be a file, not a folder. I assume it's a typo and not LMHOST as shown.

Phil,
If you have any Win9x/ME systems, I advise that you stay away from the Z: drive. As Kent and Jooel mentioned, not good practice to assume folder name based on OS. Using @INWIN and %windir% is much safer.

Try quotes around your parameters as per Jooel's example.

[ 04 February 2002: Message edited by: LLigetfa ]

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#62785 - 2002-02-04 08:27 PM Re: IF Statement
Phil Q Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 18
Loc: UK
Thanks. I will try that and let you know the outcome
Top
#62786 - 2002-02-04 08:30 PM Re: IF Statement
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
thanks les...

I just wrote thoughts without thinking so clearly on this file stuff...
thought just that it's dir 'cause of the name (missing ending "s")...

_________________________
!

download KiXnet

Top
#62787 - 2002-02-06 02:54 AM Re: IF Statement
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Our version would be:

code:

IF (Exist("c:\windows\nul") = 1) OR (Exist("c:\windows") = 1)
COPY "\\server\netlogon\lmhost" "c:\windows\." /H
IF (@error <> 0)
? "Warning KIX: error during copy file. error @error (@serror)."
ENDIF
ENDIF
IF (Exist("c:\winnt\system32\drivers\etc\nul") = 1) OR (Exist("c:\winnt\system32\drivers\etc") = 1)
COPY "\\server\netlogon\lmhost" "c:\winnt\system32\drivers\etc\." /H
IF (@error <> 0)
? "Warning KIX: error during copy file. error @error (@serror)."
ENDIF
ENDIF


We doesn't use the @inwin macro. Also it is possible to use the environment
variable %windir%. The version will be something like:
code:

$windir=ExpandEnvironmentVars("%windir%)
IF (Copy($windir,Len($windir),1) = "\") ; - remove \-character -
$windir=Copy($windir,1,Length($windir)-1)
ENDIF
;
IF (Exist("$windir\nul") = 1) OR (Exist("$windir") = 1)
COPY "\\server\netlogon\lmhost" "$windir\." /H
IF (@error <> 0)
? "Warning KIX: error during copy file. error @error (@serror)."
ENDIF
ENDIF
IF (Exist("$windir\system32\drivers\etc\nul") = 1) OR (Exist("$windir\system32\drivers\etc") = 1)
COPY "\\server\netlogon\lmhost" "$windir\system32\drivers\etc\." /H
IF (@error <> 0)
? "Warning KIX: error during copy file. error @error (@serror)."
ENDIF
ENDIF


greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#62788 - 2002-02-07 01:54 AM Re: IF Statement
Syserco Administrator Offline
Lurker

Registered: 2002-02-07
Posts: 4
Loc: Fremont
The latest version of Kixtart also has the @PRODUCTTYPE macro which can be used like:

-------------Code------------

IF @PRODUCTTYPE="Windows 98"
USE U: @HOMEDIR
ELSE
GOTO "QUIT"

:QUIT
QUIT

------------ENDCode----------

Regards,

Alex

Top
#62789 - 2002-02-07 04:12 PM Re: IF Statement
Phil Q Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 18
Loc: UK
Thanks it worked
Top
#62790 - 2002-02-08 08:35 AM Re: IF Statement
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
mca, one not wanted thing in your code exist.
on nt machine the file is copied to both locations.
that's why I wanted to use inwin-macro.
I don't see script ready when it works, but when it does what it should.

right?

_________________________
!

download KiXnet

Top
#62791 - 2002-02-11 04:09 AM Re: IF Statement
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear Lonkero,

We doesn't know which part of our reaction you are meaning. Two scripts
are there.
Even when both directories exist on your system. Only one of them is the
real WINDIR directory. The most important thing is that the required
copy will always be taken place.
On our NT systems we doesn't have the C:\WINDOWS directory.
Code should run for all windows versions was also an issue for us.

Much better is by getting the actual path by reading its registry value.
f.e. HKLM\Software\Microsoft\Windows\CurrentVersion\SystemRoot
Ever site can specify a location different from c:\windows and c:\winnt
for installing windows main software.

Our disadvantage for using "@inwin" macro is it doesn't work for XP
in a correct way. f.e. "XP home edition" is using "C:\Windows" as default
installation directory.
greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


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

Who's Online
0 registered and 584 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.069 seconds in which 0.03 seconds were spent on a total of 12 queries. Zlib compression enabled.

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