Page 2 of 2 <12
Topic Options
#153339 - 2005-12-14 11:03 PM Re: If Exist Ren & Copy
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
add this line after your move if it's failing:
@error " - " @serror ?
_________________________
!

download KiXnet

Top
#153340 - 2005-12-14 11:21 PM Re: If Exist Ren & Copy
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
Hello Jszei (Hungarian name by chance???),

It is a fairly simple process to change out the existing KiXtart files for your existing version. In fact, all that needs done is either you replace the current kixtart.exe with the new one or change your BATch file execution or User profile path to the new location. Of course, you should test out all your KiXtart scripts in the new version before commiting the change to the production environment.

I understand your frustration. It's hard to know where to look for the answers some times. For the most part, the manual will have all the KiXtart commands listed with a basic explanation of its use and some syntax questions. If you need to do something, but don't know how to in KiXtart, just post some "pseudo code" (plain english) and we'll try to help you build a KiXtart framework.

In my experience the learning curve is STEEP, especially for a non-programmer like myself. There are a lot of helpful people on this board. I hope you continue posting your questions. They're great for the community!!

P.S. (oops, looks like I replied a few posts before the end of the thread. I missed some later comments.... Tee hee)

By the way, the @error command will return an error code (usually a number) that will help define why the script is having problems at that line.

P.S.S By the way, verify the spelling of ALL files and directories, just to be absolutely confident that isn't the problem.
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#153341 - 2005-12-14 11:37 PM Re: If Exist Ren & Copy
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
Also, if you're having problems with the MOVE command it looks like Jooel wrote a UDF to do this.

"Rename UDF" http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=83392&an=0&page=15#83392

Do you know how to use UDFs?
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#153342 - 2005-12-15 12:24 AM Re: If Exist Ren & Copy
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
This code should work fine for you (it should show you if there was an error changing the file - NOTE this will run everytime unless you change the code somehow to prevent it.)

Why not just check the version of the file and only copy it if it's the wrong version ?


Break On
Dim $Source
$Source = ExpandEnvironmentVars(ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion','ProgramFilesPath'))
If Exist($Source +'\Common Files\System\MSMAPI\1033\MAPIR.DLL')
Move $Source +'\Common Files\System\MSMAPI\1033\MAPIR.DLL' $Source +'\Common Files\System\MSMAPI\1033\MAPIR.OLD'
'Moving file: ' + @ERROR + ' ' + @SERROR ?
Copy '\\mnc17p1s\NETLOGON\batch\mapirnew.dll' $Source +'\Common Files\System\MSMAPI\1033\MAPIR.DLL'
'Copying new file: ' + @ERROR + ' ' + @SERROR ?
EndIf

 

Top
#153343 - 2005-12-15 12:07 PM Re: If Exist Ren & Copy
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
SWK,
iirc, I wrote the UDF when there was no move in kixtart.
as I still think, he might have file name or path incorrect, and thus he should try the error line to see why it's failing.

obviously, if you want to show gui, you can go with my rename UDF
_________________________
!

download KiXnet

Top
#153344 - 2005-12-15 05:49 PM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
NTDOC you've come through again. Why do you think my code didn't work? I added the error line which didn't report anything and I run the code through a debugger which didn't report anything.
I ended up adding a goto statement if there already is a mapir.old file. I'm not sure how to have it check the version. I'll look through the manual to see if it tells how to do that.

Code:
 Dim $Source
$Source = ExpandEnvironmentVars(ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion','ProgramFilesPath'))
If Exist($Source +'\Common Files\System\MSMAPI\1033\MAPIR.OLD')
GOTO "reg"
Else
If Exist($Source +'\Common Files\System\MSMAPI\1033\MAPIR.DLL')
Move $Source +'\Common Files\System\MSMAPI\1033\MAPIR.DLL' $Source +'\Common Files\System\MSMAPI\1033\MAPIR.OLD'
Copy '\\mnc17p1s\NETLOGON\batch\mapirnew.dll' $Source +'\Common Files\System\MSMAPI\1033\MAPIR.DLL'
EndIf



SWK, nope not Hungarian. I'm an American mutt. The name is either Dutch or German and we're not sure if it's shortened or not. Some controversy lingers. Thank you for all your help. The positive words encourage me to learn more.

John

Top
#153345 - 2005-12-15 06:45 PM Re: If Exist Ren & Copy
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
sorry, added the errorline and it did not report anything is a false statement.
it will report even success.
you can't have such line without it reporting something.

or, you are not running the script via kixtart...
_________________________
!

download KiXnet

Top
#153346 - 2005-12-15 07:55 PM Re: If Exist Ren & Copy
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
GOTOs are bad. Every IF needs a corresponding EndIf.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#153347 - 2005-12-15 08:03 PM Re: If Exist Ren & Copy
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
Use this syntax to check file times

Code:
 
$Result = CompareFileTimes("\\someserver\somefolder\somefile", "C:\somefolder\somefile")
IF $Result = 1 or $Result = -3 ; '1'=File1 is more recent than file2, '-3'=File2 couldn't be open (nonexistant)
;do something
ENDIF



For file versions use GETFILEVERSION ("file name","versionfield")
(page 76-77 in KiXtart 4.50 Manual)
Syntax:
Code:
 $Result = GetFileVersion(@LDRIVE + "\Kix32.exe")

$Result = GetFileVersion(@LDRIVE + "\Kix32.exe", "ProductVersion" )

_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#153348 - 2005-12-15 11:09 PM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
Jooel, It's really not reporting anything. I've looked for something in the eventlog, I have no kixtart.log file and no Dr. Watson pops up. I run the script through kixstarter v3.28 as well as the command line with /d and it doesn't report anything. I'm probably missing something but I don't know what.

Why are goto's bad? What other options do I have if I want to stop it from renaming mapir.dll everytime?
Do I just add another endif to the end?
endif
endif

You said it SWK, steep learning curve.

Top
#153349 - 2005-12-15 11:13 PM Re: If Exist Ren & Copy
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
By checking the version you can decide if you want to copy / move it or not.

See post above and look in the manual. If you still need assitance with that let us know and we'll show you.

GOTO is difficult to debug and track down problems and can have scope issues. Some things which you may not understand right now, but take our word for it you'll be much better off in the long run if you stay away from the GOTO.

 

Top
#153350 - 2005-12-16 12:15 AM Re: If Exist Ren & Copy
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Basically, the way you coded it, the GOTO is not really needed. I havent bothered to analyze how KiX would process your code with the missing endif but if the second required EndIf were there, this is how it would look.
Code:
Dim $Source
$Source = ExpandEnvironmentVars(ReadValue('HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion','ProgramFilesPath'))
If Exist($Source +'\Common Files\System\MSMAPI\1033\MAPIR.OLD')
;do nothing
Else
If Exist($Source +'\Common Files\System\MSMAPI\1033\MAPIR.DLL')
Move $Source +'\Common Files\System\MSMAPI\1033\MAPIR.DLL' $Source +'\Common Files\System\MSMAPI\1033\MAPIR.OLD'
Copy '\\mnc17p1s\NETLOGON\batch\mapirnew.dll' $Source +'\Common Files\System\MSMAPI\1033\MAPIR.DLL'
EndIf
EndIf


Using the compare on the two files would cause the script to access the network share. OK if there is a chance the network version will be updated again but if this is a one time thing, you could just check the local version and string compare it.
Code:
If GetFileVersion($Source +'\Common Files\System\MSMAPI\1033\MAPIR.DLL', 'ProductVersion') <> 'whateveritssupposedtobe'
;do whatever
EndIf

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

Top
#153351 - 2005-12-16 01:24 AM Re: If Exist Ren & Copy
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
jscei,
lets take a crash course in kixtart.
create a text file in notepad.
place only the error line in it:
@error " - " @serror ?

and then save the file, with what ever name you wish.
then go to the folder your kixtart executable resides, and execute it:
kix32 myscriptpath\myscriptFile.txt

the output is:
0 - Operation completed successfully.

and, that's what it reports.
every time you run kixtart script and you have the errorline there, it will give you output.
if you can't see it, the part of the script where your errorline is, isn't running at all, or you are not watching.
_________________________
!

download KiXnet

Top
#153352 - 2005-12-19 11:40 PM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
Well that was a good lesson Jooel. The Kixstarter program didn't show the error and whatever I did before with the command line was wrong because I got an error code return. The problem was in the path. there was a \ at the end and it couldn't find the path specified.

Les and NTDOC thank you for your help I will be educating myself from this post for a while.

Top
#153353 - 2005-12-22 05:06 PM Re: If Exist Ren & Copy
jszei Offline
Fresh Scripter
***

Registered: 2005-12-01
Posts: 17
Well, I've run into another issue. It seems that the file can not be renamed by the standard Windows user account. Is there a way to call the admin account to perform this action?

Thanks

Top
#153354 - 2005-12-22 05:37 PM Re: If Exist Ren & Copy
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yes and no.
you can use something like runAs but surely you know that giving the admin account visible to normal user account makes your system vulnerable.

anyways, if you wish to go with runAs, search the board for examples.
_________________________
!

download KiXnet

Top
#153355 - 2005-12-22 05:39 PM Re: If Exist Ren & Copy
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh and best thing would be to make a admin script that scans all the wksta's and does the change.
_________________________
!

download KiXnet

Top
Page 2 of 2 <12


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

Who's Online
0 registered and 657 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.076 seconds in which 0.032 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