WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Shortcut Information

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Profiles and Making Shortcuts on the Desktop

Keywords:     shortcutdir  desktop profiles

Question on Shortcuts and Multiple Profiles:

I put pptview.exe (powerpoint viewer) in c:\flip. I want to make a shortcut on the user's desktop using:
        ShortcutMake("pptview.lnk.", "c:\windows\desktop","","c:\flip", @NORMAL)
I am getting a create error message, in the case of PC's where there are multiple user profiles (ie. many users sharing the same PC). In such case, the shortcuts failed to appear on the Desktop.

How do I check the existence of multiple profiles ? how do I know which profile is currently active ?

Answer:

WinBatch 97D and later versions solution:

	desktop=ShortCutDir("Desktop")
	; following line *might* needs a \ in the middle
	lnkfile=strcat(desktop,"pptview.lnk")
	target="c:\flip\pptview.exe")

	ShortcutMake(lnkfile, target,"","c:\flip", @NORMAL)
The ShortcutDir("Desktop") function gives the directory of the current user's Desktop. It searches a particular place in the registry, below, which is a more universal method of finding out the desktop (look up Winbatch Registry commands and discussion).
   UserDir = RegQueryValue(@REGCURRENT, "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders[Desktop]")
works for all versions of Winbatch 32bit.

The following work for the current user only. If you want the Default user to get it, the answer is:

   DefaultDir = RegQueryValue(@REGUSERS, ".Default\Software\Microsoft\Windows\CurrentVersion\Explorer\ShellFolders[Desktop]")
In the case above, you may need to copy all .LNK files from DefaultDir to UserDir on login if you want users to have all the default icons.

Look in Regedit under RegUsers and you will see 1 or 2 keys. If you see one key, it will be .Default, and this equals @REGCURRENT (Current user).

If you see two keys, then the other one is used and is the logged in username and that key and subkeys equals @REGCURRENT.

Pick up a good beginner's book on the Registry for more information.


Another Question, RE: Copying Icons in NT4.0:

I am new to winbatch.Can anyone tell me how I can copy a shortcut from a network drive to the users desktop. The user will be a different user each time the batch file is run. I need a way to obtain the userid and then to have that information included in the location of where the icon will be stored in the user profile.

Answer:

I think you will have to do a shortcutmake to create the icon anew each time.

Get the userid from the registry:

   userid=RegQueryValue(@REGMACHINE, "SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\[DefaultUserName]")
   change to the desired directory then shortcutmake to create the icon

   DirChange("C:\Winnt\Profiles\All Users\Start Menu\Programs\Startup")
   ShortcutMake("QuotaB.lnk", "C:\Winbatch\QuotaB.exe", "", "C:\Winbatch", @NORMAL)
and include %userid% in the new shortcut somewhere
Article ID:   W13849
Filename:   Profiles and Making Shortcuts on the Desktop.txt
File Created: 1999:04:15:16:56:48
Last Updated: 1999:04:15:16:56:48