#153340 - 2005-12-1411:21 PMRe: If Exist Ren & Copy
StarwarsKidStarwarsKid
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
#153342 - 2005-12-1512:24 AMRe: If Exist Ren & Copy
NTDOCNTDOC 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 ?
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
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.
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.
#153347 - 2005-12-1508:03 PMRe: If Exist Ren & Copy
StarwarsKidStarwarsKid
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:
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
#153349 - 2005-12-1511:13 PMRe: If Exist Ren & Copy
NTDOCNTDOC 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.
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.
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.
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.
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?
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.