Hi all ... 'nother newbie here - great board BTW ...
I've amalgamated some scripts I've got here to create a test login for our network ... and I have a few shortcuts included ... but alas, one of the shortcuts I want to have the icon changed to one I made in Fireworks but it's not having any of it ... any suggestions?
Code:
; NLC Login script updated 11/03/2006 - Niall
;************************************************************************* ; Run logon scripts visable ;
If @INWIN = ("1") WriteValue("$HKLMSMWNTCV\winlogon","RunLogonScriptSync","1","REG_DWORD") EndIf
CLS SMALL Color b+/n BOX (0,0,24,79,GRID) ; background grid Color b/n BOX (2,3,13,77,Å) ; shadow of the box Color g+/n BOX (1,2,20,76,FULL) ; Green box Color b+/n
Select Case ((@TIME > "00:00:00") And (@TIME < "12:00:00")) Color c+/n AT(11,5) "Good Morning @fullname" AT(12,5) "You are now connecting to the National Lottery NLCHQ domain." Color r+/n AT(13,5)"Please wait - Network authentication is being verified . . ." Color g+/n Sleep 2 Case ((@TIME > "12:00:00") AND (@TIME < "18:00:00")) Color c+/n AT(11,5) "Good Afternoon @fullname" AT(12,5) "You are now connecting to the National Lottery NLCHQ domain." Color g+/n AT(13,5)"Please wait - Network authentication is being verified . . ." Color g+/n Sleep 2 Case 1 Color c+/n AT(11,5) "Good Evening @fullname" AT(12,5) "You are now connecting to the National Lottery NLCHQ domain." Color r+/n AT(13,5)"Please wait - Network authentication is being verified . . ." Color g+/n Sleep 1 EndSelect
Color w+/n AT (2,5) "Userid : " ; label for user and network identification text strings AT (3,5) "Full Name : " AT (4,5) "Workstation : " AT (5,5) "NT Domain : " AT (6,5) "Logon Server : " AT (7,5) "OS : " AT (8,5) "Service Pack : " Color y+/n AT (2,20) @userid ; macro's for user and network identification text strings AT (3,20) @fullname AT (4,20) @wksta AT (5,20) @domain AT (6,20) @lserver ; Lists the authenticating server AT (7,20) @ProductType AT (8,20) @CSD AT (9,65) ; Moves the cursor to the end of the message
:AddMaps
; BREAK OFF $MUpdate= "Your NETWORK DRIVES are now being connected..." $pick = 1
At (16,15) "$Mupdate" sleep 2
; BREAK OFF COLOR r+/w$X = 2 WHILE $X < 80 BOX(18,6,2,$x,"full") $X = $X + 10 SLEEP 1 LOOP COLOR w/n
function wshShortCut($shortcutname,$targetpath,optional $arguments, optional $startdir, optional $iconpath, optional $style,optional $description,optional $hotkey) dim $shell, $desktop, $shortcut, $index, $iconinfo, $iconindex,$scdir $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 $=writeprofilestring($shortcutname,"InternetShortcut","IconFile",$iconpath) $=writeprofilestring($shortcutname,"InternetShortcut","IconIndex",$iconindex) endif $shortcut = 0 $wshshortcut=0 else exit @error endif else exit @error endif endfunction
In addition, when I try and specify for the Shortcut to start maximized - 3 - again - no joy ...
I'm not too up on the wshshortcut function and I'd really appreciate it if I could see a syntax example with all switches activated - just to check to see where I'm mishandling this ...
BTW - the login script is called by a .bat file on the AD that copies the a kix folder to the users drive and then calls kix from there - I've thrown in the .ico file into here aswerll so all files are local prior to kix kicking off ...
This batch guy here..
Code:
net use k: \\addc1\kixtart if not exist c:\kixtart md c:\kixtart copy k:\*.* c:\kixtart call c:\kixtart\callkix.bat net use k: /del
Sorry for not replying sooner - just in for the Monday workload ... thanks for your reply BTW ...
Allen, I've tried your suggestion and still no luck with the icon changing...it is being carried down from the server into the kix dir alright, but it's just not grabbing the file to change it on the shortcut...
I've played around with the softlink also - but no joy there either ..
I'm a tad stumped at the mo' ... Any other suggestions welcome ...
In addition, as you can see I've two shortcuts being created. Both of which are created with the IE Standard icon ... but apart from this ... when the first Shortcut is activated - say the Webvision one - it opens up in an IE window - that's grand. Now if the user goes ahead and cranks up lotterynet then - what happens is that it opens up in the same window as Webvision started up in which restults in the user losing all work done in the WebV window up to that point ..
Might there be a way I can tell each shortcut to open up in it's own window?
Thanks a million again,
Niall
____________________ Dream is destiny
_________________________
____________________ Dream is Destiny
Nia... not sure why its not working for you, but I might suggest you make sure the icon file is on the target computer, and that the user has permission to access it.
I just tested this with the latest version of wshShortCut and it worked fine for me. Code:
Wow! Thanks a million for you're suggestions .. I've tried all but still no joy. The fact that it's working for y'all is a tad disconcerting yet curiously re-assuring - I've nothing unusual on any of the PC's I'm trying and it's still being stubborn. Allen - I have the .ico file being copied locally at each logon to a dir along with the kix.exe and associated files and then the kix runs locally and (in theory) looks for the ico file in the same dir from whence the exe itself originated... looking in the dir after login shows the .ico there but no change on the desktop.
I've checked the properties of the file that's copied down and it's got 'Everyone' with Full Access only .. which should be grand. One thing I have noticed is that a 1 and a 0 appear after my progress bar during login but no errors are reported ... curious ... I had a look at a few posts relating to ones and zeroes - but it seems that all the code in the script is terminated OK ... The ones and zeroes only began appearing after I introduced the wshshortcut into the fix ...
No errors are reported on the creation of the shortcut either NTDOC - mayhap because the shortcut is actually created and workable but the only thing amiss is the icon not being right....which might not be deemed as erroneous to windows? Even just copying and pasting you're code into the script here, created the eBay icon with the standard IE 'E' but no errors about the 'ebay.ico. file missing or anything ..
I thought it might be something with the .ico file I created which was a .jpg scanned file converted to .ico using a program called 'Image to Icon' converter by helixsoft .. so I decided to try a standard pre-packaged windows icon to see if it would take - and guess what? No joy either! Crikey - it's getting into a 'Me versus the Icon' situ here and it's getting to be one of those niggly probs that get under your skin and even though it's doesn't hold THAT much gravity - it's still one that I refuse to get the better of me ..
(feckin' icons!!)
So I'll soldier on - I wouldn't blamn all y'all if you want to carry on with your bigger fishes to fry - but I'll keep this post updated as and when my hair progressively thins!!
(there goes another clump!)
Thanks again,
Niall ___________________ Dream is Destiny
_________________________
____________________ Dream is Destiny
The reason for the 0's and 1's are they are the return codes from the WSHshortcut function. Most functions return something. If you'll notice in my and Doc's examples we prefix our lines with a variable to catch it.
Just for kicks...try adding this to your the end of your script...
Code:
$=RefreshDesktop()
function RefreshDesktop() dim $rd $rd=SetFocus("Program Manager") $rd=SendKeys("{F5}") endfunction
I've managed to get rid of the 1's and 0' ... thanks a mill Allen! the refresh code was added all to no avail tho' .. DOH! I had a skip in me heart when you suggested it - looked like a winner, and then ... nowt!
I've tried recreating the icon, deleting the old and replacing the one on the AD PDC, and using a '%systemroot%\kixtart\lottery.ico' string in the wshshortcut - no go ... also the '\\PDCNAME\original share\lottery.ico' - no go ..
The shortcut goes onto the desktop and the url is set etc ... after that it seems to ignore the code and just jumps to the drive mappings etc...
Also, the '3' option to start in a maximized window is also ignored BTW - I was gonna leave that one until I got this sorted but it might be that the two are interrlated somehow now...
I copied and stripped the script just down to the 'wshshortcut' function aswell, logged back on and the shortcuts were created and working but the icon change is still not biting...
I'm looking for a way to sorta 'roundhouse kick' the icon into activity - hence the using %systemroot% etc ...any other suggestions welcome...
I'm still baffled as to how you guys have the thing working tho' ...
_________________________
____________________ Dream is Destiny
It seems I need to document that Web shortcuts do not "appear" to support MAX/Min modes via normal way of creating shortcuts. With that said it is still possible. Try these examples and describe your results:
Code:
$=wshShortcut("Notepad","%systemroot%\system32\notepad.exe",,,"%systemroot%\system32\cmd.exe") ? @serror $=wshShortcut("KiXtart Web Page","http://www.kixtart.org",,,"%systemroot%\system32\cmd.exe") ? @serror $=wshShortcut("IE - MAX New Window","%systemroot%\system32\cmd.exe","/c start /max iexplore -new http://www.ebay.com",,"%systemroot%\system32\cmd.exe") ? @serror
Results as requested: I tried your code as suggested and the first line procuded nothing on the desktop for me ... (notepad) The second produced the bog standard IE icon with operable shortcut .. The third produced a shortcut that opened in a maximized window with an icon of the cmd.exe (DOS wnidow) sort ... Opening the cmd shortcut first opens a new window and opening the second Shortcut afterwards opens it up in the same window ... the other way round opens them up in their respective windows ... Out of curiousity I modified your code to remove the "%systemroot%\system32\cmd.exe" at the end and replaced it with our path to the locally downloaded icon file and guess what?!? - IT WORKED!!!
Logging in now creates shortcuts that open in their respective windows and there's nice company relative icons to help those 'non-au fait' end-users identify programs easier ... Brilliant I say!
Yahoo to you! Sincere thanks for your staying alongside me on this one ... it's much appreciated. Now I can roll our our new intranet with a nice snazzy icon as a a launchpad too!...
Thanks Allen and thanks to the others who suggested/helped on this!
A nice start to this soggy Irish Wednesday morn ...
N
_________________________
____________________ Dream is Destiny
Did anyone test with nia's posted version of the UDF? I did not compare his posted code with the current version of the UDF. Maybe it is old or modified code.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
CLS SMALL Color b+/n BOX (0,0,24,79,GRID) ; background grid Color b/n BOX (2,3,13,77,Å) ; shadow of the box Color g+/n BOX (1,2,20,76,FULL) ; Green box Color b+/n
Select Case ((@TIME > "00:00:00") And (@TIME < "12:00:00")) Color c+/n AT(11,5) "Good Morning @fullname" AT(12,5) "You are now connecting to the National Lottery NLCHQ domain." Color r+/n AT(13,5)"Please wait - Network authentication is being verified . . ." Color g+/n Sleep 2 Case ((@TIME > "12:00:00") AND (@TIME < "18:00:00")) Color c+/n AT(11,5) "Good Afternoon @fullname" AT(12,5) "You are now connecting to the National Lottery NLCHQ domain." Color g+/n AT(13,5)"Please wait - Network authentication is being verified . . ." Color g+/n Sleep 2 Case 1 Color c+/n AT(11,5) "Good Evening @fullname" AT(12,5) "You are now connecting to the National Lottery NLCHQ domain." Color r+/n AT(13,5)"Please wait - Network authentication is being verified . . ." Color g+/n Sleep 1 EndSelect
Color w+/n AT (2,5) "Userid : " ; label for user and network identification text strings AT (3,5) "Full Name : " AT (4,5) "Workstation : " AT (5,5) "NT Domain : " AT (6,5) "Logon Server : " AT (7,5) "OS : " AT (8,5) "Service Pack : " Color y+/n AT (2,20) @userid ; macro's for user and network identification text strings AT (3,20) @fullname AT (4,20) @wksta AT (5,20) @domain AT (6,20) @lserver ; Lists the authenticating server AT (7,20) @ProductType AT (8,20) @CSD AT (9,65) ; Moves the cursor to the end of the message
:AddMaps
; BREAK OFF $MUpdate= "Your NETWORK DRIVES are now being connected..." $pick = 1
At (16,15) "$Mupdate" sleep 2
; BREAK OFF COLOR r+/w$X = 2 WHILE $X < 80 BOX(18,6,2,$x,"full") $X = $X + 10 SLEEP 1 LOOP COLOR w/n
Use with /delete but without /persistent is overly optimistic. You failed to handle the return: WriteValue("$HKLMSMWNTCV\winlogon","RunLogonScriptSync","1","REG_DWORD") and I don't see where $HKLMSMWNTCV is defined. and as DOC said, don't use vars in strings. $RC = WriteValue($HKLMSMWNTCV + "\winlogon","RunLogonScriptSync","1","REG_DWORD")
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.