Page 1 of 1 1
Topic Options
#194856 - 2009-07-16 09:31 PM Copy url to %USERPROFILE%\desktop
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
I have tried to get the copy to the users desktop with no success.
This is what I have added to my logon gpo kix logon script which is working great:

if ingroup("SC_Testing")
copy "\\domain.local\SysVol\domain.local\Policies\{F7CD01DB-B9EA-4B06-B24B-F60F5AAFD4BB}\User\Scripts\Logon\DeathCertsOnline.url" "%USERPROFILE%\desktop\DeathCertsOnline.url"
endif

I have also tried: (with the if/endif markers)
copy "DeathCertsOnline.url" "%USERPROFILE%\desktop"

and every permutation of the above 2. with and without the url name as a destination, with and without the full pathname of the url
I can run on my pc the command in a kix file and it works.

I have the shortcut in the \\domain.local\SysVol\domain.local\Policies\{F7CD01DB-B9EA-4B06-B24B-F60F5AAFD4BB}\User\Scripts\Logon directory

Will either or both of the above work?? testing is difficult because my testing device is a laptop and that takes forever to get updates to gpo

Is there an easier way??



Edited by Karon (2009-07-16 09:34 PM)
Edit Reason: change to question

Top
#194864 - 2009-07-17 09:29 AM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
DeathCertsOnline? Kinda creepy

 Originally Posted By: Karon

....
Is there an easier way??



Yes there is.
You can use the WSHShortcut UDF for this. See the example below. All you need to do is change the URL to the website. Do not change the WSHShortcut function itself because it is a UDF and it comes ready for use.

 Code:
Break on

$rc = wshShortcut("DeathCertsOnline", "http://www.somewebsite.com") 

;DO NOT MODIFY ANYTHING BELOW THIS LINE.
;IT IS A UDF AND COMES READY FOR USE.
; 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
#194865 - 2009-07-17 01:15 PM Re: Copy url to %USERPROFILE%\desktop [Re: Mart]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
The only think kreepier than the URL is poking into a UNC path of your policies. ;\)

Welcome to KORG, by the way..

As far as GPO testing, have you tried opening a command prompt and run "GPUPDATE /FORCE" ?? I do that when I bring new systems onto the domain and the policies drop down in about 30 seconds. We use WSUS, and I can get it to configure, sync, and load the initial set of updates via GPO in just a few minutes.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194866 - 2009-07-17 02:36 PM Re: Copy url to %USERPROFILE%\desktop [Re: Mart]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
So Mart,
Please correct me if I wrong, but -
I thing it might should read the following:
If ingroup("SC_TESTING")
wshShortCut (DeathCertsOnline, %USERPROFILE%\Desktop)
ENDIF

The url DeathCertsOnline is actually
https://ter2.dshs.state.tx.us:8443/ThinTXDeathTest/src/LoginModule/Maintest.html

this is contained in the ad location and the DeathCertsOnline is the internet shortcut name I have given to it.


Thanks so much!!

Top
#194867 - 2009-07-17 02:40 PM Re: Copy url to %USERPROFILE%\desktop [Re: Glenn Barnas]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
Hey Glenn - I do run the gpupdate /force, which works quickly on a pc and not so much with a wireless tablet - which blows bad...

The reason I had the full pathname was that I am SOOOOOOO frustrated with this. The internet shortcut is actually in the unc path for the logon script, but wanted to cover ALL my bases in every way possible!

I think I will be good with Mart's suggestion on wshShortCut.

Cross you fingers and think good thoughts for me!!

Top
#194868 - 2009-07-17 02:42 PM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
The only thing you need to change is the URL to the website.

Your script would look like this (do not forget to include the WSHShortcut UDF):
 Code:
If InGroup("SC_TESTING")
	$rc = wshShortCut("DeathCertsOnline", "https://ter2.dshs.state.tx.us:8443/ThinTXDeathTest/src/LoginModule/Maintest.html")
EndIf



Edited by Mart (2009-07-17 02:44 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#194869 - 2009-07-17 02:48 PM Re: Copy url to %USERPROFILE%\desktop [Re: Mart]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
Working it right now!! give me a couple of minutes to get the laptop logged on.. Thanks for the prompt reply!!!

I would kill for a test pc instead!!

Top
#194870 - 2009-07-17 02:49 PM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
quick question - is the udf already out there or should I copy/create the thing???? should that be in the policy path as well??
Top
#194871 - 2009-07-17 02:59 PM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
You should put nothing in the policy path that is not placed there by the policy. I always avoid these folders like the plaque and only make modification to them by modifying a policy with the GPO management console.

Everything can be in netlogon/sysvol as part of your logon script.
The WSHShortcut UDF is already written by Allen. I included it in my first post and it is also available in the UDF section of this board.

UDF Library » wshShortcut() - v1.3 - Create File & Web Shortcuts
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#194872 - 2009-07-17 02:59 PM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
Hey - I just read thru the UDF again.
I have changed the 2nd line to
$rc = wshShortcut("DeathCertsOnline", "https://ter2.dshs.state.tx.us:8443/ThinTXDeathTest/src/LoginModule/Maintest.html")

the filename is currently
wshDeathCerts.txt
I am going to assume I can place the file in the policy path and change the extension to udf and the script would read:
if ingroup("SC_Testing")
wshDeathCerts
endif

would that work or have I lost my mind???

Top
#194873 - 2009-07-17 03:01 PM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Like I said, put nothing in the policy path.

This can be part of your logon script. The UDF should be part of your script or called from your script. I posted a fully working solution with the If ingroup(...) stuff.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#194874 - 2009-07-17 03:04 PM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
The reason I ask is I am just now getting into the guts of KiXtart and working thru naming conventions, locations for files etc.

Thanks for taking the time to assist a kixnewbie!!

Top
#194875 - 2009-07-17 03:14 PM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
No problem.

Below is a step by step description of what you need to do to get this working.

-1 fire up a text editor (notepad, notepad++, etc... a kix editor would be even better).
-2 create a new file and paste the code below in it.

 Code:
If InGroup("SC_TESTING")
	$rc = wshShortCut("DeathCertsOnline", "https://ter2.dshs.state.tx.us:8443/ThinTXDeathTest/src/LoginModule/Maintest.html")
EndIf

;DO NOT MODIFY ANYTHING BELOW THIS LINE.
;IT IS A UDF AND COMES READY FOR USE.
; 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 


-3 Make sure that you are a member of the SC_TESTING group.
-4 Run the script manually on your system.
-5 The new shortcut should be on your desktop.
-6 make this new script a part of your logon script or call it from your logon script.
-7 Everybody that is a member of the SC_TESTING group will now get the shortcut on the desktop the next time they logon.

There is one issue with this:
Every time a member of the SC_TESTING logs on he/she will get the shortcut. You can skip creating the shortcut if it is there already but let’s look at that later and get the basics running first.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#194876 - 2009-07-17 05:00 PM Re: Copy url to %USERPROFILE%\desktop [Re: Mart]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
 Originally Posted By: Mart
I always avoid these folders like the plaque

Fear not - an annual visit to your dentist can resolve any plaque issues.. now the PlaGue, on the other hand is definitely something to avoid! \:D

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194877 - 2009-07-17 05:06 PM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
There are many ways to handle UDFs. Some create a central share and reference them via CALL '\\server\UDFshare\function.udf' statements, which load the UDFs dynamically each time the script runs - the advantage is the UDFs are centrally maintained and the script always gets the latest copy of the UDF. The disadvantage is that the script always gets the latest version of the UDF. ;\) Basically, with a central, dynamic repository, you need to test every dependent script whenever you change a UDF.

Others (like me) like to keep the UDFs on a central share, but bind them into our code during development. Some do this via copy/paste, and some of us use my KGen tool to enumerate your script and dynamically build a script with all UDF dependencies included. This freezes the build with the current UDF versions, which allows you to take your time to test dependent scripts. KGen also runs Sanity on the finished script, looking for common coding errors such as missing EndIf, Loop, & Done clauses and mismatched quotes and parens.


It really comes down to what you're comfortable with in your environment. Find a way that works for you and stick with it.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#194883 - 2009-07-17 09:27 PM Re: Copy url to %USERPROFILE%\desktop [Re: Mart]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
Got that one working!!
If it recreates the shortcut, will it name it #2 or just overwrite?

Never mind - I tested and it just recreates the shortcut


Edited by Karon (2009-07-17 09:30 PM)
Edit Reason: answered my own question

Top
#194884 - 2009-07-17 11:23 PM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
Hey, do I put commas with spaces to add the $iconpath?
Top
#194885 - 2009-07-18 01:05 AM Re: Copy url to %USERPROFILE%\desktop [Re: Karon]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Arguments to UDFs are positional, so - if you wanted to specify (for example) arguments 1 and 4 out of 6, you would write
 Code:
CoolFunc('Arg1',,,'Arg4')
, essentially passing blank args for 2 & 3, and ignoring 5 & 6.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

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 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.207 seconds in which 0.088 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