#153411 - 2005-12-15 01:50 AM
Creating a SendTo for notepad
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11624
Loc: CA
Code to create a shortcut to the SendTo for notepad so that you can easily right click and send a file to notepad for further analysis without having to wait for the Open With It also creates one in the Default User profile so the next new user to logon will have it available as well. Uses the wshShortCut UDFBreak On Dim $SO $SO =SetOption ('Explicit' ,'On' )$SO =SetOption ('NoVarsInStrings' ,'On' )$SO =SetOption ('NoMacrosInStrings' ,'On' ) Dim $PLKey ,$SendTo ,$DefUser ,$W $PLKey ='HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' $SendTo = ExpandEnvironmentVars (ReadValue ('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' ,'SendTo' ))$DefUser = ExpandEnvironmentVars (ReadValue ($PLKey ,'ProfilesDirectory' ))+'\' +ReadValue ($PLKey ,'DefaultUserProfile' )$W =wshShortCut ($SendTo +'\Notepad' ,'%SystemRoot%\notepad.exe' ,,,'%SystemRoot%\notepad.exe,0' ,,,)$W =wshShortCut ($DefUser +'\SendTo\Notepad' ,'%SystemRoot%\notepad.exe' ,,,'%SystemRoot%\notepad.exe,0' ,,,) 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 ($shortcutname ,".lnk" ) and not exist ($targetpath ) exit 2 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
Top
Moderator: Jochen , Allen , Radimus , Glenn Barnas , ShaneEP , Ruud van Velsen , Arend_ , Mart
0 registered
and 242 anonymous users online.