Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: shortcuts shortcutmake DDE Progman
For example: C:\WINDOWS\Start Menu\ C:\WINDOWS\Desktop\To manipulate Files and Folders, use the WinBatch File and Shortcut commands. We've created some sample code demonstrating how you might manipulate the Windows Explorer to reflect your changes in Groups and Icons.
Firstly, determine whether you're on a Windows 95 or NT 4.0 machine, before proceeding further. If you know you're on an appropriate system, you can skip this part in your own code.
if ( (WinMetrics(-4) >= 4) && (WinVersion(@MAJOR)>=4)) ; Win95 or NT 4.0 Explorer=AppExist("Explorer") else Explorer=0 ; for all else force explorer off endif If Explorer == 0 Message("Group and Icon Test", "No Explorer found, exiting program.") exit endif
AddExtender("WWNET34I.DLL") USERNAME=Environment("USERNAME") ShortCutMake("C:\WINNT\PROFILES\%USERNAME%\SENDTO\WinZip62.lnk","V:\WINAPPS\WINZIP.62\WINZIP.EXE","V:\WINAPPS\WINZIP.62\WINZIP.EXE","V:\WINAPPS\WINZIP.62\",@NORMAL)
thestart="C:\Windows\Start Menu\"However, be aware. This approach will not work in all circumstances. The Start Menu could be in another place. The fool proof way to find the Start Menu and other program icon information is to look in the Registry.
strtdir=RegQueryValue(@REGCURRENT,"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders[Programs]") Message("GET PROGRAM DIRECTORY", "The start directory is %@CRLF% %@CRLF% %strtdir%. %@CRLF%%@CRLF% Look under Explorer to verify.")
First check to see if the destination directory you want already exists. If it doesn't exist, then create it with DirMake. Change to this new directory.
newdir="%strtdir%\Yowsa" If DirExist (newdir) == @true DirChange(newdir) else DirMake(newdir) DirChange(newdir) endif Message("CREATE A GROUP", "The new directory is %@CRLF%%@CRLF% %newdir%")
The Windows 95 interface has a handy feature which allows you to access a file from multiple places. Instead of leaving multiple copies of files here and there, you can create a shortcut which points to the exe. A shortcut can be placed in a dozen different places without the hoopla of needing to install again or waste disk space or deal with file version management.
In making an icon, you can copy a file to a directory with the command FileCopy or you can use ShortcutMake to create a *.lnk file. In our example, ShortcutMake will create a few icons in the current directory. Before we create them though, we will check to see if they're already there with FileExist.
if FileExist("Add Me Up.lnk") == @FALSE ShortcutMake("Add Me Up.lnk", "C:\WINDOWS\CALC.EXE", "", "C:\WINDOWS\", @NORMAL) endif if FileExist("write my notes.lnk") == @FALSE ShortcutMake("write my notes.lnk", "C:\WINDOWS\NOTEPAD.EXE", "", "C:\WINDOWS\", @NORMAL) endif if FileExist("Solitaire.lnk") == @FALSE ShortcutMake("Solitaire.lnk", "C:\WINDOWS\sol.exe", "", "C:\WINDOWS\", @NORMAL) endif Message("CREATE AN ICON", "Feel free to look under %newdir% for the new files.")
if FileExist("write my notes.lnk") == @TRUE then FileDelete("write my notes.lnk") if FileExist("Solitaire.lnk") == @TRUE then FileDelete("Solitaire.lnk") Message("DELETE AN ICON", "Now check %newdir%. %@CRLF%%@CRLF% Were two of the files deleted?")
;DirRemove(newdir)in this case would result in an error. "1030 DirRemove: Dir not removed." Delete the semi-colon and run it if you'd like to see the error first hand.
So, if the directory needs to be empty, then you'll need to empty it. Try the following:
filelist=FileItemize("*.*") ;Grab a list of files in the current directory. Use a loop to delete the files... count=ItemCount(filelist, @TAB) ;Count the number of files in the directory. For i = 1 to count ;Delete the files in a loop item=ItemExtract(i, filelist, @TAB) ;Grab each file one at a time FileDelete(item) ;Delete the file Next FileDelete(filelist) ; ...Or delete the list in one commmand. DirChange("C:\") ; Change to a different directory so the other can be removed. DirRemove(newdir) ; With the directory empty of files, DirRemove should now work. message("DELETE A GROUP", "The directory has been removed. %@CRLF%%@CRLF% We're done.")Now you should have all the necessary pieces to wreck havoc with your users' directories. Deleting their favorite icons, changing their groups, hiding their files.
exit
Article ID: W13855
Filename: Shortcuts Take over From ProgMan - Examples.txt
File Created: 2001:03:01:12:21:34
Last Updated: 2001:03:01:12:21:34