#113474 - 2004-02-06 11:21 AM
Help..strange character t the end of value?
|
Grutte Pier
Getting the hang of it
Registered: 2001-10-06
Posts: 52
Loc: Leeuwarden, The Netherlands
|
Hello,
I've make this script using two functions (udfSqueeze and WshPipe) and all goes just fine but when I write the value to the reg the value shows at right place but at the end a strange character that looks like a Pipe ("|") is added to the value. The value sould be: \\servername\NSSVOL1\USERS\ICT\BILLG but it shows: \\servername\NSSVOL1\USERS\ICT\BILLG|
this is my code: Code:
; ----------------------------------------------------------------------- ; Doc_path.kix ; ----------------------------------------------------------------------- ; The script changes the destination of the default document location of ; the applications: ; MS Excel ; MS Word ; MS Powerpoint ; ----------------------------------------------------------------------- ; Samengesteld door Frans Erich ; ----------------------------------------------------------------------- ; Updated by ; ; ----------------------------------------------------------------------- ; Dependencies ; - Kixtart version 4.1 or later ; - Function udfSqueeze ; - Function WshPipe ; - Windows Script Host ; ----------------------------------------------------------------------- ; Credits to ; The builetin board communities of www.kixtart.org and www.kixscripts.com ; Special thanks to builetin board modorators: ; - Richard H. ; - sealeopard ; - Chris S. ; - NTDOC ; ----------------------------------------------------------------------- ; Variables $search=" H:" $word_key="HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Word\Options" ; -----------------------------------------------------------------------
Function udfSqueeze($sSource,Optional $sDelimiters, Optional $bTrim) Dim $iSourceLength $iSourceLength=0 Dim $iIndex $iIndex=0 Dim $iLastGood $iLastGood=0 Dim $bFound $bFound=0 $udfSqueeze="" ; -------------------------- ; Defaults and sanity checks ; -------------------------- If $sDelimiters="" $sDelimiters=" " EndIf If $bTrim $bTrim=1 Else $bTrim=0 EndIf ; ---------------------------------------- ; High speed squeeze for single characters ; ---------------------------------------- If Len($sDelimiters)=1 $sDelimiters=""+$sDelimiters+$sDelimiters $iIndex=InStr($sSource,$sDelimiters) While $iIndex $sSource=""+SubStr($sSource,1,$iIndex)+SubStr($sSource,$iIndex+2,Len($sSource)) $iIndex=InStr($sSource,$sDelimiters) Loop If $bTrim $sDelimiters=SubStr($sDelimiters,1,1) ; ------------- ; Trim leading. ; ------------- While SubStr($sSource,1,1)=$sDelimiters $sSource=SubStr($sSource,2,Len($sSource)) Loop ; -------------- ; Trim Trailing. ; -------------- $iIndex=Len($sSource) While SubStr($sSource,$iIndex,1)=$sDelimiters $sSource=SubStr($sSource,1,$iIndex-1) $iIndex=Len($sSource) Loop EndIf $udfSqueeze=$sSource Else ; -------------------------------------- ; Slower squeeze for multiple characters ; -------------------------------------- $iSourceLength=Len($sSource) For $iIndex = 1 To $iSourceLength $cChar=SubStr($sSource,$iIndex,1) If InStr($sDelimiters,$cChar) If $bFound=0 AND ( $iLastGood OR $bTrim=0 ) $udfSqueeze=""+$udfSqueeze+SubStr($sDelimiters,1,1) EndIf $bFound=1 Else $bFound=0 $udfSqueeze=""+$udfSqueeze+$cChar If $bTrim $iLastGood=Len($udfSqueeze) EndIf EndIf Next If $iLastGood $udfSqueeze=SubStr($udfSqueeze,1,$iLastGood) EndIf EndIf EndFunction Function WshPipe($ShellCMD, OPTIONAL $NoEcho) Dim $oExec, $Output $oExec = CreateObject("WScript.Shell").Exec($ShellCMD) If NOT VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf While NOT $oExec.Status Loop $Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll If NOT $NoEcho $Output EndIf $WshPipe=Split($Output,Chr(10)) Exit($oExec.ExitCode) EndFunction
Break on $rc=WshPipe("%comspec% /c net use",1) For Each $line In $rc If InStr($line,$search) $linepart=Split(udfSqueeze($line," ","true")) $ = WriteValue ($word_key,"DOC-PATH",$linepart[2],"reg_sz") ? $linepart[2] EndIf Next :END
Thanks,
GP
|
|
Top
|
|
|
|
#113483 - 2004-02-06 04:44 PM
Re: Help..strange character t the end of value?
|
Grutte Pier
Getting the hang of it
Registered: 2001-10-06
Posts: 52
Loc: Leeuwarden, The Netherlands
|
I've got it.
Code:
; ----------------------------------------------------------------------- ; Doc_path.kix ; ----------------------------------------------------------------------- ; The script changes the destination of the default document location of ; the applications: ; MS Excel ; MS Word ; MS Powerpoint ; ----------------------------------------------------------------------- ; Samengesteld door Frans Erich ; f.j.erich@ict.azg.nl ; f.erich@chello.nl ; ----------------------------------------------------------------------- ; Updated by ; ; ----------------------------------------------------------------------- ; Dependencies ; - Kixtart version 4.1 or later ; - Function udfSqueeze ; - Function WshPipe ; - Windows Script Host ; ----------------------------------------------------------------------- ; Credits to ; The builetin board communities of www.kixtart.org and www.kixscripts.com ; Special thanks to builetin board modorators: ; - Richard H. ; - sealeopard ; - Chris S. ; - NTDOC ; ----------------------------------------------------------------------- ; Variables $search = " H:" $word_key = "HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Word\Options" $excel_key = "HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\Excel\Microsoft Excel" $powerpoint_key = "HKEY_CURRENT_USER\Software\Microsoft\Office\8.0\PowerPoint\Recent Folder List\Default" ; -----------------------------------------------------------------------
Function udfSqueeze($sSource,Optional $sDelimiters, Optional $bTrim) Dim $iSourceLength $iSourceLength=0 Dim $iIndex $iIndex=0 Dim $iLastGood $iLastGood=0 Dim $bFound $bFound=0 $udfSqueeze="" ; -------------------------- ; Defaults and sanity checks ; -------------------------- If $sDelimiters="" $sDelimiters=" " EndIf If $bTrim $bTrim=1 Else $bTrim=0 EndIf ; ---------------------------------------- ; High speed squeeze for single characters ; ---------------------------------------- If Len($sDelimiters)=1 $sDelimiters=""+$sDelimiters+$sDelimiters $iIndex=InStr($sSource,$sDelimiters) While $iIndex $sSource=""+SubStr($sSource,1,$iIndex)+SubStr($sSource,$iIndex+2,Len($sSource)) $iIndex=InStr($sSource,$sDelimiters) Loop If $bTrim $sDelimiters=SubStr($sDelimiters,1,1) ; ------------- ; Trim leading. ; ------------- While SubStr($sSource,1,1)=$sDelimiters $sSource=SubStr($sSource,2,Len($sSource)) Loop ; -------------- ; Trim Trailing. ; -------------- $iIndex=Len($sSource) While SubStr($sSource,$iIndex,1)=$sDelimiters $sSource=SubStr($sSource,1,$iIndex-1) $iIndex=Len($sSource) Loop EndIf $udfSqueeze=$sSource Else ; -------------------------------------- ; Slower squeeze for multiple characters ; -------------------------------------- $iSourceLength=Len($sSource) For $iIndex = 1 To $iSourceLength $cChar=SubStr($sSource,$iIndex,1) If InStr($sDelimiters,$cChar) If $bFound=0 AND ( $iLastGood OR $bTrim=0 ) $udfSqueeze=""+$udfSqueeze+SubStr($sDelimiters,1,1) EndIf $bFound=1 Else $bFound=0 $udfSqueeze=""+$udfSqueeze+$cChar If $bTrim $iLastGood=Len($udfSqueeze) EndIf EndIf Next If $iLastGood $udfSqueeze=SubStr($udfSqueeze,1,$iLastGood) EndIf EndIf EndFunction Function WshPipe($ShellCMD, OPTIONAL $NoEcho) Dim $oExec, $Output $oExec = CreateObject("WScript.Shell").Exec($ShellCMD) If NOT VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf While NOT $oExec.Status Loop $Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll If NOT $NoEcho $Output EndIf $WshPipe=Split($Output,Chr(10)) Exit($oExec.ExitCode) EndFunction
Break on $CharNr = "" $rc=WshPipe("%comspec% /c net use",1) For Each $line In $rc If InStr($line,$search) $linepart=Split(udfSqueeze($line," ","true")) ; The next 3 lines strip a cha $CharNr = Len ($linepart[2]) $CharNr = $CharNr - 1 $pad = Left ($linepart[2],$CharNr) $ = WriteValue ($word_key,"DOC-PATH",$pad,"reg_sz") $ = WriteValue ($excel_key,"DefaultPath",$pad,"reg_sz") $ = WriteValue ($powerpoint_key,"",$pad,"reg_sz") $linepart[2] ? EndIf Next :END
Thanks a lot for the help you gave,
GP
|
|
Top
|
|
|
|
#113486 - 2004-02-11 01:39 PM
Re: Help..strange character t the end of value?
|
Grutte Pier
Getting the hang of it
Registered: 2001-10-06
Posts: 52
Loc: Leeuwarden, The Netherlands
|
That generates this error:
Invalid method/function call: missing ')'!
in line 120
And line 120 is:
the just added line Code:
"in ascii that is:" Asc(rigth($linepart,1)) ?
thanks,
GP
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 756 anonymous users online.
|
|
|