Jump to content


  • 0
jamitupya

Windows 7 SetStart.vbs

Question

Hey guys, trying to dynamically create a shortcut in the start menu but failing misserably... point is to start this link during our OSD for Windows 7....for all intensive purposes, it should work, but wont display the link in the all users.... ideas?

 

 

' Initialization
Program = "SetStart.vbs"

Set shell = CreateObject("Wscript.Shell")


' Create the shortcut and point it to the specified script (assume C:\Build)

' path = shell.SpecialFolders("ProgramData") & "C:\Profiles\Profiles\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" & "\Startup.lnk"
path = "C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\Startup" & "\Startup.lnk"
Set link = shell.CreateShortcut(path)
link.TargetPath = "C:\Build\" & WScript.Arguments.Item(0)  ' Name of the file to start
If WScript.Arguments.Count > 1 then
   plog "Link = " & WScript.Arguments.Item(1)
   link.Arguments = WScript.Arguments.Item(1)  ' Parameters to pass
End if
link.Save

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

nah, permissions are ok, puts the file there, just doesnt seem to work...weird

 

 

try this:

 

Dim WSHShell

Set WSHShell = WScript.CreateObject("WScript.Shell")

 

 

Dim MyShortcut, MyDesktop, DesktopPath

 

DesktopPath = WSHShell.SpecialFolders("Desktop")

 

Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\Shortcut to notepad.lnk")

 

MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings("%windir%\notepad.exe")

MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("%windir%")

MyShortcut.WindowStyle = 4

MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("%windir%\notepad.exe, 0")

MyShortcut.Save

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.