Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Create Shortcut On Desktop


  • Please log in to reply
12 replies to this topic

#1 jwinathome

jwinathome

  • Members
  • 1,360 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Atlanta, Georgia
  • Local time:02:24 AM

Posted 04 September 2007 - 12:41 PM

Any help or information is greatly appreciated.

This is probably more simple than I am making it, but here goes:


All I need to do is create a desktop shortcut to a folder....

There is a folder:

C:\C2S\UEI\Images (In this folder, tiff images that are scanned get stored.)

I need to create a desktop shortcut to the above, but need it scripted because this shortcut has to be created every time we get a new user, or a user switches desks.


Again, thank you kindly.

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:24 AM

Posted 04 September 2007 - 01:06 PM

Am I correct in assuming then that you want it to become a customization feature, for lack of a better term. In other words, when a system is booted up, you want that shortcut to appear, no matter what user is logged on, or where they are logged on? It should be simple enough to create a .reg file that installs the key to local_machine. I am not sure how to do it right off, but .reg files are easy to make, and I am sure that there is a sample somewhere on the Internet.

The other alternative is a simple batch file that runs whenever a user logs on.

#3 jwinathome

jwinathome
  • Topic Starter

  • Members
  • 1,360 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Atlanta, Georgia
  • Local time:02:24 AM

Posted 04 September 2007 - 01:37 PM

It doesn't necessarily have to be when they log on, because there are certain customizations (currently) that I have to setup personally anyway, so I am essentially the one logging on. In other words, I pretty much set it up myself.

Further explanation:

I already have a batch file containing several registry changes as well as setting up certain drives, etc....I would like to add this simple shortcut to that batch file. Does that make sense?

I looked for a reference point in the registry earlier but couldn't find anything. Usually the programs set up their own registry key as to whether or not a shortcut is placed on the desktop. However, this poorly written imaging software we use does not have that written into their installation, and the keys necessary for that customization aren't present.

Edited by jwinathome, 04 September 2007 - 01:39 PM.


#4 mommabear

mommabear

  • Members
  • 492 posts
  • OFFLINE
  •  
  • Local time:02:24 AM

Posted 04 September 2007 - 02:38 PM

Can you just create (send to ) the shortcut on your desktop and then drag it to the all All Users-Desktop folder? I think the path would be here:

C:\Documents and Settings\All Users\Desktop

#5 jwinathome

jwinathome
  • Topic Starter

  • Members
  • 1,360 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Atlanta, Georgia
  • Local time:02:24 AM

Posted 04 September 2007 - 04:45 PM

Well, I thought of that originally, but after doing some checking, there will be people that float to those desks (and people that come in after hours to do "piece work") on these computers that shouldn't have the shortcut. (Even though they could still access the folder), but they are less likely to do so if there is no shortcut. (The reason is that these are contracts that have confidential information.)

I know it sounds like a bad setup, and a mess, but its what I inherited.

#6 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:24 AM

Posted 04 September 2007 - 06:53 PM

I was going to suggest a script, but that will make it available to all users. Are the 'floaters' using their own accounts, or how are authentications done on the machines?

#7 jwinathome

jwinathome
  • Topic Starter

  • Members
  • 1,360 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Atlanta, Georgia
  • Local time:02:24 AM

Posted 05 September 2007 - 06:10 AM

Yes, even the floaters are set up in AD. Do you mind going ahead and posting the script for the all users?

I appreciate your help groovicus.

#8 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:24 AM

Posted 05 September 2007 - 08:12 AM

Sure. It's not my code, but here it is:
' This code creates a shortcut.

set objWSHShell = CreateObject("WScript.Shell")

' Pass the path to the shortcut
set objSC = objWSHShell.CreateShortcut("d:\mylog.lnk") 

' Description - Description of the shortcut
objSC.Description = "Shortcut to MyLog file"

' HotKey � hot key sequence to launch the shortcut
objSC.HotKey = "CTRL+ALT+SHIFT+X"

' IconLocation � Path of icon to use for the shortcut file
objSC.IconLocation = "notepad.exe, 0"  ' 0 is the index

' TargetPath = Path to source file or folder
objSC.TargetPath = "c:\windows\notepad.exe"

' Arguments � Any additional parameters to pass to TargetPath
objSC.Arguments = "c:\mylog.txt"

' WindowStyle � Type of window to create
objSC.WindowStyle = 1   ' 1 = normal; 3 = maximize window; 7 = minimize

' WorkingDirectory � Location of the working directory for the source app
objSC.WorkingDirectory = "c:\"
objSC.Save
WScript.Echo "Shortcut to mylog created"


http://techtasks.com/code/viewbookcode/518

Another method:
http://mikesalsbury.com/mambo/content/view/547/

I may have misspoke. I can't recall if this is only for single user or not.

#9 jwinathome

jwinathome
  • Topic Starter

  • Members
  • 1,360 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Atlanta, Georgia
  • Local time:02:24 AM

Posted 05 September 2007 - 08:42 AM

I inserted my specific folders and it works like a charm.

One more question...Is there a relatively easy way to amend this script to validate that the folder exists before creating a shortcut?

(I know I'm asking a lot.)

#10 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:24 AM

Posted 05 September 2007 - 09:47 AM

If (FileSystemObject.FileExists(sFileName)) Then

CheckFileExists = True

Else

CheckFileExists = False

End If


#11 jwinathome

jwinathome
  • Topic Starter

  • Members
  • 1,360 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Atlanta, Georgia
  • Local time:02:24 AM

Posted 06 September 2007 - 07:57 AM

How would I insert my shortcut code inside that If:Then statement?

In other words,

IF its true and the folder is present, THEN I want the shortcut created,

IF its false and the folder is not there, THEN I want the script to end.

#12 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:12:24 AM

Posted 06 September 2007 - 04:58 PM

It would be something like:
If (FileSystemObject.FileExists(sFileName)) Then

	'This code creates a shortcut.
	set objWSHShell = CreateObject("WScript.Shell")

	' Pass the path to the shortcut
	set objSC = objWSHShell.CreateShortcut("d:\mylog.lnk")

	' Description - Description of the shortcut
	objSC.Description = "Shortcut to MyLog file"

	' HotKey � hot key sequence to launch the shortcut 
	objSC.HotKey = "CTRL+ALT+SHIFT+X"

	' IconLocation � Path of icon to use for the shortcut file
	objSC.IconLocation = "notepad.exe, 0"  ' 0 is the index

	' TargetPath = Path to source file or folder
	objSC.TargetPath = "c:\windows\notepad.exe"

	' Arguments � Any additional parameters to pass to TargetPath
	objSC.Arguments = "c:\mylog.txt"

	' WindowStyle � Type of window to create
	objSC.WindowStyle = 1   ' 1 = normal; 3 = maximize window; 7 = minimize

	' WorkingDirectory � Location of the working directory for the source app
	objSC.WorkingDirectory = "c:\"
	objSC.Save
	WScript.Echo "Shortcut to mylog created"

End If

EDIT: This is not tested; I just cut and pasted the necessary pieces.

#13 jwinathome

jwinathome
  • Topic Starter

  • Members
  • 1,360 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Atlanta, Georgia
  • Local time:02:24 AM

Posted 06 September 2007 - 08:54 PM

Thank you kindly for your help groovicus.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users