|
|
|||||||
So have run across KIX but never worked with it. I'm now under the gun to use it to do what I think should be a simple task... replace drive mappings. I personally hate them but the place I'm at has run them forever and you know how users can get .. if it's not on the "L:" drive they have no clue. Now, corporate security (and I've been at this game too long not to see a big stick that I can wield) has said "get rid of drive maps .. now!" . Seems too many have gotten burned with various forms of crypto locker & variants. Anyway, been told to make this happen .. started looking at KIX and am already seeing things I'd like to try but I need this basic thing very fast and hope somebody could send me one example or steer me in the right direction to get me started. Our login scripts do nothing but map drives .. 6 to be precise ... and a "Z:" to the users home folder ... so all I want to do is replace the NET USE G: \\server\public with a shortcut on their desktop .. I guess using an ICON of some sort (maybe if I can make it look nice they'll complain less? .. naaa) Thanks up front .... |
||||||||
|
|
|||||||
If it is really this simple, you should be able to do something like the following for each of the mapped drives. Keep in mind that shortcuts will be over-written to the desktop every time they log in with the way the code is below. Code: if exist("G:\") USE G: \\server\public /delete /persistent endif $RC=wshshortcut("Public on Server","\\server\public") You will need the UDF WshShortCut - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=84115#Post84115 How to use UDFs - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943 The rest of the UDFs are here - http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1 |
||||||||
|
|
|||||||
A simple fix to avoid multiple shortcuts for the same and to make sure it points to the correct drive (user can do strange things). Code: If Exist("G:\") Use G:\\server\public /delete /persistent EndIf $desktop = ExpandEnvironmentVars(%userprofile%) $desktop = $desktop + "\Desktop" If Exist($desktop + "\Public on server.lnk") Del $desktop + "\Public on server.lnk" EndIf $RC = wshshortcut("Public on Server", "\\server\public") |
||||||||
|
|
|||||||
Mart, The code I posted will just overwrite the existing Shortcut, and only recreate it if the shortcut has been deleted or renamed. |
||||||||
|
|
|||||||
Oh ok. I thought it just created a shortcutname (2) style shortcut if it already exists. Learned something. BTW: if it are shortcuts to drives then setting a nice drive icon for the shortcut will make the transition easier for the users. Just a cosmetic remark not a requirement. |
||||||||
|
|
|||||||
FYI - My Universal Login Script can do drive mappings, shortcuts, or both. With this, you can transition from drives to both to just shortcuts. GUI management, free and commercial support, and lots of ways to manage resource mapping, including AD attribute, network subnet, user or computer OU in addition to the usual by-Group control. More info is available here. Glenn |
||||||||
|
|
|||||||
Well I thought it was simple .. I did this ... copied the UDF to this below Exit 1 ... and ran it. It puts a file on my desktop OK .. named G .. but it's not a .lnk .. it's a file and if you click on it the system prompts you as to what to open it with. So what did I miss? Code: if exist("G:\") USE G: \\frafile\shared /delete /persistent endif $RC=wshshortcut("G:_Drive","\\frafile\shared") Exit 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 right($targetpath,2)=",1" $targetpath=left($targetpath,-2) 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 |
||||||||
|
|
|||||||
Are you sure its not a link? Might you open a command prompt and navigate to %userprofile%\desktop directory and do a dir *.lnk to see if it is there, or just a dir to see what kind of file it is. Also, noticed a bug in the sample code... this line USE G: \\frafile\shared /delete /persistent should have quotes around the server path USE G: "\\frafile\shared" /delete /persistent |
||||||||
|
|
|||||||
Oh... its the ":". Not a valid character for file names. |
||||||||
|
|
|||||||
Originally Posted By: Allen You will need the UDF WshShortCut - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=84115#Post84115 or http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=7&Number=82930 |
||||||||
|
|
|||||||
I am a bit late to the question and I don't think that my solution would help you with cases like cryptolocker etc. But if you are interested I created code to add libraries to the windows 7 libraries and pointed them to locations on the server! I also redirected existing libraries to locations on the server. I suspect that cryptolocker would be able to affect libraries so probably not any use to you, but if you just want to get rid of mapped drives - I could find my code for you! |
||||||||
|
|
|||||||
Originally Posted By: Allen Oh... its the ":". Not a valid character for file names. So with the other answers I'm looking at the rest and then I saw this one and I said .. ":"? .. then .. sure that was it it now works perfect .. Thank you guys .... |