View Full Version : Send to Startup folder (All)
homeflash
02-07-2003, 08:07 PM
Does anyone know if there is a command line that will send create a shortcut of a program and send it to the startup short cut folder?
It would be nice it can be done either by windows command or visual basic.
thanks
*** Sometimes Helping is a way of Learning! ***
Mosaic1
02-09-2003, 05:21 PM
In XP this script will create a shortcut to Notepad and put it in the current user's startup folder. It also includes the option to cancel.
I copied the original script from my Win98 SE Samples\WSH folder and modified it a little. It originally created a shortcut on the desktop.
' Windows Script Host Sample Script
'
' ------------------------------------------------------------------------
' Copyright (C) 1996-1997 Microsoft Corporation
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Microsoft has no warranty,
' obligations or liability for any Sample Application Files.
' ------------------------------------------------------------------------
' This sample demonstrates how to use the WSHShell object to create a shortcut
' on the desktop.
L_Welcome_MsgBox_Message_Text = "This script will create a shortcut to Notepad in your Startup Folder."
L_Welcome_MsgBox_Title_Text = "Windows Scripting Host Sample"
Call Welcome()
' ************************************************** ******************************
' *
' * Shortcut related methods.
' *
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
Dim MyShortcut, MyStartUp, StartUpPath
' Read Startup path using WshSpecialFolders object
StartUpPath = WSHShell.SpecialFolders("StartUp")
' Create a shortcut object inthe StartUp Folder
Set MyShortcut = WSHShell.CreateShortcut(StartUpPath & "\Shortcut to notepad.lnk")
' Set shortcut object properties and save it
MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings("%windir%\System32\notepad.exe")
MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("%windir%\system32")
MyShortcut.WindowStyle = 4
MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("%windir%\system32\notepad.exe, 0")
MyShortcut.Save
WScript.Echo "A shortcut to Notepad now exists in your Startup Folder"
' ************************************************** ******************************
' *
' * Welcome
' *
Sub Welcome()
Dim intDoIt
intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
vbOKCancel + vbInformation, _
L_Welcome_MsgBox_Title_Text )
If intDoIt = vbCancel Then
WScript.Quit
End If
End Sub
dudeinAmerica
02-24-2003, 08:34 PM
Well it took me about 10 minutes to think about, and about 30 minutes to compile it.
This is the concept:
You have to go in to the program folder, for example, <font color=red>C:\Program Files\Internet Explorer</font color=red>, now close everything, so that just the folder and the desktop are showing. Now drag <font color=red>Iexplore.exe</font color=red> over to <font color=red>Project1.exe</font color=red> (or your executable file of the following code supposively in this example on the desktop). Upon load, the application will activate returning a message box saying that it was added to the Windows startup. What happens is that the "Command" varible is the location of the executable file that has just been dragged upon <font color=red>Project1.exe</font color=red>. The app then uses the Windows Registry to save it's location to the startup key.
Make sure you enabled the <font color=red>Windows Script Host Object Model</font color=red> or <font color=red>wshom.ocx</font color=red> (usually found in the system directory).
This is the code that should be compiled into an executeable file:
<font color=green>
Private Sub Form_Load()</font color=green><font color=blue>
Set x = New WshShell
If Command = "" Then GoTo done
ext = UCase(Right(Command, 3)) <font color=green>'Gets the extension of the file</font color=green>
If ext <> "EXE" Then GoTo done <font color=green>'If the file dragged is not an executable file, it unloads</font color=green>
x.regwrite "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\Run\" + Right(Command, 12), Command
MsgBox "Program added to Windows startup."
done:
Unload Me</font color=blue>
<font color=green>End Sub
</font color=green>
This is actually a great idea for a program. All it needs is developing. You're probably thinking right now, "what the heck?," but try it out, and I think you'll understand more. If you'd like a copy of this program in an executable format, send me a private message. I'll be happy to assist you in anyway I can.
Hope this works for you!
/images/forums/icons/cool.gifBrady/images/forums/icons/cool.gif
Powered by vBulletin™ Version 4.1.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.