#209029 - 2014-06-25 05:43 AM
First basic script
|
Dekkar
Just in Town
Registered: 2014-06-25
Posts: 4
Loc: Syd, Aus
|
Hi guys, hopefully this is a very basic script... Its the first one ive tried and also my first post.
Basically I wanted the script to do the following:
If C:\file.doc exists exit
else
copy \\server\file.doc c:\
then exit.
Is this possible with Kixtart?
Thanks, dekkar
|
|
Top
|
|
|
|
#209036 - 2014-06-27 08:49 AM
Re: First basic script
[Re: Jochen]
|
Dekkar
Just in Town
Registered: 2014-06-25
Posts: 4
Loc: Syd, Aus
|
Excellent... Ill give it a test run.
Thanks for the info.
|
|
Top
|
|
|
|
#209118 - 2014-07-01 07:32 AM
Re: First basic script
[Re: Dekkar]
|
Dekkar
Just in Town
Registered: 2014-06-25
Posts: 4
Loc: Syd, Aus
|
Hi Guys, after a bit of playing around and hunting around, I found that kix can inject registry files directly, so my script now looks like:
IF NOT KeyExist("HKCU\Software\Work\Config\IncludeSubjectLabel") $rc = WriteValue("HKCU\Software\Work\Config\", "IncludeSubjectLabel", "0", "REG_DWORD") $rc = WriteValue("HKCU\Software\Work\Config\", "IncludeSubjectLabelOnBrowse", "0", "REG_DWORD") ENDIF
I do have a question, for some reason, the script is executing even if the key exists.
For example, if I change this key to have a value of "1", then relogon, it changes to "0".... So its changing the registry regardless of the IF NOT.
Is there something I'm missing?
|
|
Top
|
|
|
|
#209122 - 2014-07-01 12:24 PM
Re: First basic script
[Re: Mart]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
|
Actually, Mart's example will show that the value located at the Key path is empty. A small distinction, but important to understand as a new scripter. If you need to know if it didn't exist instead of being empty, you could read the location into a variable, then check @ERROR. If the ERRROR macro contained the value "2", then it did not exist.Break on
$key = "HKCU\Software\Work\Config"
$RC = ReadValue($key, "IncludeSubjectLabel")
If @ERROR = 2
$rc = WriteValue($key, "IncludeSubjectLabel", "0", "REG_DWORD")
$rc = WriteValue($key, "IncludeSubjectLabelOnBrowse", "0", "REG_DWORD")
EndIf Also - Registry objects consist of a Key and Value. Values contain Data of a specific Type - this info is needed to Write the object. You can think of the KEY as the PATH and VALUE like the FILE in a disk structure. Functions that deal with keys won't include the value part, which was the issue in your first attempt.
If it's simply important that the registry object contain specific data, then it doesn't matter what method you use.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#209147 - 2014-07-02 02:34 AM
Re: First basic script
[Re: Glenn Barnas]
|
Dekkar
Just in Town
Registered: 2014-06-25
Posts: 4
Loc: Syd, Aus
|
Hi Guys, thanks for shedding some light on this.
Both examples I understand and have expanded my knowledge on scripting...
Its now working as expected! Which is kind of satisfying!
Thanks again.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|