Page 1 of 1 1
Topic Options
#193778 - 2009-05-12 09:39 AM humm maybe a newbe question : )
joselino Offline
Fresh Scripter

Registered: 2009-05-12
Posts: 9
Loc: France
Hello Everyone,

I got a problem with the kixtart scripting ( but you can already figured that : p ) :

humm so my boss asked me if i could modify a kix or use a new one, to add a favorites in internet explorer on every computer of the company.

So is it possible ? And if it is possible what are the methods or attributes used for this modification?

Best regards,

Joselino

Top
#193780 - 2009-05-12 11:57 AM Re: humm maybe a newbe question : ) [Re: joselino]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Hi Joselino,

Welcome to the board. In short yes. If you just want to add favorites to each person's profile as they log in, you could do it in the login script. You just place them under %userprofile%\Favorites. Do you have anything you are starting with, or is this brand new?

Regards,

Brad

Top
#193781 - 2009-05-12 12:07 PM Re: humm maybe a newbe question : ) [Re: BradV]
joselino Offline
Fresh Scripter

Registered: 2009-05-12
Posts: 9
Loc: France
Hi Brad,

Thanks for your answer but how do you place them under favorites coz i used the Copy command to copy / paste some txt but the favorites like for example Google isn't copied to the destination directory.

I think that the problem is that the file extention is not good, i tried .lnk .url but none works.

It's weird coz i have a feeling that this shortcut / favorites has no particular extension.

Do you have any idea on this ?

Regards,

Joselino

Top
#193782 - 2009-05-12 12:17 PM Re: humm maybe a newbe question : ) [Re: joselino]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Gold platter time \:\)


There is the WSHShortcut UDF that can do that for you.

The script below creates a shortcut in the Favorites folder for Google.

 Code:
Break on

$userprofile = ExpandEnvironmentVars(%userprofile%) + "\Favorites\"

$rc = wshShortcut($userprofile + "Google", "http://www.google.com")   

;=-=-=-=-=-=-=-=-= DO NOT MODIFY ANYTHING BELOW THIS LINE. =-=-=-=-=-=-=-=-=
;=-=-=-=-=-=-=-=-= THIS IS A UDF AND IT COMES READY FOR USE AS IT IS. =-=-=-=-=-=-=-=-=
;
; wshShortCut(),   
;   
;Authors and Contributors:   
; Shawn, Radimus, Al_Po,   
; Richard Farthing, NTDOC   
;   
;Version:   
; 1.3.4   
;   
;Action:   
; Creates Shortcuts for files or Web pages   
;   
;Syntax:   
; wshShortCut($shortcutname,$targetpath,optional $arguments, optional $startdir, optional $iconpath, optional $style, optional $Description)   
;   
;Parameters:   
; SHORTCUTNAME 	Required. Name of Shortcut. If path is omitted, will be saved to desktop.   
; TARGETPATH 	Required. The path the target point to.  To ommit checking if path exists in the function, append the target path 
;                         with ",1"   
; ARGUMENTS 	Optional. Arguments appended to TARGETPATH   
; STARTDIR 	Optional. Working Directory   
; ICONPATH 	Optional. Path to Icon Library. To specify an icon other than the first, separate the icon path with   
;                   	  ",#" where # represents the icon in the library.   
; STYLE 	Optional. 1 = default, 3 = maximized window, 7 = minimized window   
; DESCRIPTION 	Optional. Description or Comment about Shortcut   
; HOTKEY 	Optional. Keyboard Hotkey.  (Note:  Shortcut must be saved to desktop or startmenu for Hotkey to function) 
;   
;Remarks:  
; wshShortCut 1.3.4 
; - Dimmed undimmed var 
; wshShortCut 1.3.3 
; - Added option to bypass TARGETPATH exist check on LNK shortcuts.  Add ,1 to the end of your Targetpath to bypass 
;   See Example below. 
; wshShortCut 1.3.2 
; - Included Option for HotKey(.hotkey)  
; wshShortCut 1.3.1  
; - Bug Fixes when creating URL shortcuts  
; wshShortCut 1.3  
; - Attempts to create directory structure to shortcut if it does not exist  
; wshShortcut 1.2:   
; - Support for NoVarsinStrings   
; - Checks for existence of TargetPath in .lnk files   
; - Included option for Description (.description)   
; wshShortcut 1.1:   
; - fixes a logic bug in wshShortCut 1.0 so you can use more than icons 0-9 in a icon library on URLS.   
; - Unless path is explicity stated in $ShortCutName, icons are created on the desktop   
; - If .lnk or .url is omitted, UDF tries to determine the shortcut type, but defaults to .lnk if it can't figure it out.   
; wshShortCut 1.0   
; http://www.kixtart.org/ubbthreads/showfl...=true#Post81769   
;   
;Examples:   
; $=wshShortcut("KiXtart Web Page","http://www.kixtart.org")   
; $=wshShortcut("Notepad","%systemroot%\system32\notepad.exe")   
; $=wshShortcut$=wshshortcut("Server1","\\Server1,1") 
 

 

Function wshShortCut($shortcutname, $targetpath, optional $arguments, optional $startdir, optional $iconpath, optional $style, optional $description, optional $hotkey)
	Dim $shell, $desktop, $shortcut, $index, $iconinfo, $iconindex, $scdir, $rc
	$wshshortcut = 1
	$shell = CreateObject("wscript.shell")
	If $shell
		If UCase(Right($shortcutname, 4)) = ".URL" Or UCase(Right($shortcutname, 4)) = ".LNK"
			;do nothing 
		Else
			If UCase(Left($targetpath, 5)) = "HTTP:" Or UCase(Left($targetpath, 6)) = "HTTPS:" Or UCase(Left($targetpath, 4)) = "FTP:"
				$shortcutname = $shortcutname + ".url"
			Else
				$shortcutname = $shortcutname + ".lnk"
			EndIf
		EndIf
		If InStr($targetpath, ",")
			$targetpath = Split($targetpath, ",")[0]
		Else
			If InStr($shortcutname, ".lnk") And Not Exist($targetpath)
				Exit 2
			EndIf
		EndIf
		If InStr($shortcutname, "\") = 0
			$Desktop = $shell.SpecialFolders("Desktop")
			$shortcutname = $desktop + "\" + $shortcutname
		Else
			$scdir = SubStr($shortcutname, 1, InStrRev($shortcutname, "\"))
			If Not Exist($scdir)
				MD $scdir
				If @error
					Exit @error
				EndIf
			EndIf
		EndIf
		$shortcut = $shell.createshortcut($shortcutname)
		If $shortcut
			$shortcut.targetpath = $targetpath
			If $iconpath And InStrRev($shortcutname, ".lnk")
				$shortcut.iconlocation = $iconpath
			EndIf
			If $arguments
				$shortcut.arguments = $arguments
			EndIf
			If $startdir
				$shortcut.workingdirectory = $startdir
			EndIf
			If $style
				$shortcut.windowstyle = $style
			EndIf
			If $description And InStrRev($shortcutname, ".lnk")
				$shortcut.description = $description
			EndIf
			If $hotkey
				$shortcut.hotkey = $hotkey
			EndIf
			$shortcut.save
			If @error
				Exit @error
			EndIf
			If InStrRev($shortcutname, ".url") And $iconpath
				$index = InStrRev($iconpath, ",")
				If $index = 0
					$iconindex = 0
				Else
					$iconindex = Split($iconpath, ",")[1]
					$iconpath = Split($iconpath, ",")[0]
				EndIf
				$rc = WriteProfileString($shortcutname, "InternetShortcut", "IconFile", $iconpath)
				$rc = WriteProfileString($shortcutname, "InternetShortcut", "IconIndex", $iconindex)
			EndIf
			$shortcut = 0
			$wshshortcut = 0
		Else
			Exit @error
		EndIf 
	Else
		Exit @error
	EndIf 
EndFunction   
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#193784 - 2009-05-12 12:38 PM Re: humm maybe a newbe question : ) [Re: Mart]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Ah, perfect. I knew there was a UDF, I just couldn't find it. \:\)

If you have more than a few favorites to create, you can place them in an ini file and then have your script read them with readprofilestring and run through them. If you only have a few to create, its not worth the extra effort.

Regards,

Brad

Top
#193788 - 2009-05-12 02:27 PM Re: humm maybe a newbe question : ) [Re: BradV]
joselino Offline
Fresh Scripter

Registered: 2009-05-12
Posts: 9
Loc: France
Hi Mart,

Thanks for your effort : ) but i kin have another problem i think that the .UDF files is not really called by my kix script, because the google favorites is not added to my i.e : (

I called the udf files with this line :

Call @ScriptDir + "\test.udf"

Is it a good way to do it ?

Or should i put it directly after?

regards ,

Joselino

Top
#193790 - 2009-05-12 02:38 PM Re: humm maybe a newbe question : ) [Re: joselino]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Hi Joselino,

You need to put excatly what Mart supplied in a kixtart file, such as:

Make_IE_Favorites.kix

Then run it. From a command line, issue:

kix32 Make_IE_Favorites.kix

That will put the google link in the current logged in user's Favorites.

Run that as a test. Next, if that works, figure out all the Favorites that you want to create. If it is a few, just put them in like the google one. One right after the other. For example:
 Code:
$rc = wshShortcut($userprofile + "Google", "http://www.google.com")
$rc = wshShortcut($userprofile + "Yahoo", "http://www.yahoo.com")
$rc = wshShortcut($userprofile + "Kixtart", "http://www.kixtart.org")


Let us know how that works. Remember, this is just a test and not ready to deploy.

Regards,

Brad

Top
#193793 - 2009-05-12 03:18 PM Re: humm maybe a newbe question : ) [Re: BradV]
joselino Offline
Fresh Scripter

Registered: 2009-05-12
Posts: 9
Loc: France
Hi BradV,

I did exactly what you told me but nothing happened ...
I tried to see what was in the %userprofiles%
but there is nothing in this var unlike in %username% or any other var.

Did there is a problem with this var or the syntax ???


regards,

Joselino

Top
#193795 - 2009-05-12 03:36 PM Re: humm maybe a newbe question : ) [Re: joselino]
joselino Offline
Fresh Scripter

Registered: 2009-05-12
Posts: 9
Loc: France
Hi guys,

My bad : ), the script is working the mistakes was that your script is in english (Favorites) and our computers are in french so it's Favoris and not Favorites :x

Anyway thanks for your help and patience : )

Best Regards,

Joselino

Top
#193798 - 2009-05-12 04:22 PM Re: humm maybe a newbe question : ) [Re: joselino]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
LOL D#mn those other languages

We have English Windows and office on all our system here @ work even in the remote office in FR, DE, ES, CH and IT. Makes life as an admin a lot easier.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#193806 - 2009-05-13 05:42 AM Re: humm maybe a newbe question : ) [Re: Mart]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Reading from the Registry takes the name guessing out of the equation.
In some cases there are some folders you just can't locate properly in the Registry, but in this case you can easily.

This code "should" work on all language versions of Windows XP. The folder name physically on the drive may be named differently but the wording in the Registry I believe is in English. If its not please let me know.

 Code:
Dim $ShellFolders, $CUFavs
$ShellFolders = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders'
$CUFavs = ExpandEnvironmentVars(ReadValue($ShellFolders, 'Favorites'))
? 'Favorites folder location is: ' + $CUFavs

Top
#193810 - 2009-05-13 09:17 AM Re: humm maybe a newbe question : ) [Re: NTDOC]
joselino Offline
Fresh Scripter

Registered: 2009-05-12
Posts: 9
Loc: France
Hi NTDOC,

First sorry to have replied so lately, we are on a different timezone : ).

I tried to use your Code but, it dosn't work i paste it to obtain a code like this :

 Code:
Break on

Dim $ShellFolders, $CUFavs

$ShellFolders = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders'

MessageBox("$ShellFolders","titre",32)

$CUFavs = ExpandEnvironmentVars(Readvalue($ShellFolders, 'Favorites'))

MessageBox("$CUFavs","titre",32)


$rc = wshShortcut($CUFavs + "TDA en Ligne", "http://www.tdaenligne.com")

;=-=-=-=-=-=-=-=-= DO NOT MODIFY ANYTHING BELOW THIS LINE. =-=-=-=-=-=-=-=-=
;=-=-=-=-=-=-=-=-= THIS IS A UDF AND IT COMES READY FOR USE AS IT IS. =-=-=-=-=-=-=-=-=
;
; wshShortCut(),   
;   
 


Don't care about messagebox \:\)



Regards,

Joselino

Top
#193811 - 2009-05-13 09:59 AM Re: humm maybe a newbe question : ) [Re: joselino]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Did the Messagebox show the correct path?
Top
#193812 - 2009-05-13 12:24 PM Re: humm maybe a newbe question : ) [Re: NTDOC]
joselino Offline
Fresh Scripter

Registered: 2009-05-12
Posts: 9
Loc: France
the messagebox with the $shellfolders shows the correct path

the messagebox with the $CUFavs shows also the correct path

but in the end nothing happened \:\(

Top
#193813 - 2009-05-13 12:25 PM Re: humm maybe a newbe question : ) [Re: joselino]
joselino Offline
Fresh Scripter

Registered: 2009-05-12
Posts: 9
Loc: France
Maybe it's about the Readvalue or something ??
Top
#193814 - 2009-05-13 12:55 PM Re: humm maybe a newbe question : ) [Re: joselino]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
Hi Joselino,

DOC was just trying to show you how to get the "Favorites" folder no matter what the language is. You still need to use what Mart gave you, but where he had
 Code:
$userprofile = ExpandEnvironmentVars(%userprofile%) + "\Favorites\"
$rc = wshShortcut($userprofile + "Google", "http://www.google.com")


Instead use:
 Code:
$rc = wshShortcut($CUFavs + "Google", "http://www.google.com")


Regards,

Brad

Top
#193829 - 2009-05-13 05:49 PM Re: humm maybe a newbe question : ) [Re: BradV]
joselino Offline
Fresh Scripter

Registered: 2009-05-12
Posts: 9
Loc: France
Oki thanks bradV : )
Top
Page 1 of 1 1


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

Who's Online
0 registered and 515 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.073 seconds in which 0.026 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