Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub help
- wscript.echo "shortcut [options] {shortcut file} {target [arguments...]}" _
- & vbcrlf & "Options:" & vbcrlf _
- & "/dir {path} Set working directory." & vbcrlf _
- & "/desc {str} Set description." & vbcrlf _
- & "/hk {str} Set hotkey. e.g.: ctrl+alt+f9" & vbcrlf _
- & "/icon {path,num} Set icon. e.g.: d:\dir\file.dll,-2" & vbcrlf _
- & "/show {num} Set show mode. 0=normal, 3=maximized, 7=minimized"
- wscript.quit 1
- end sub
- if wscript.arguments.count < 2 then help
- scf = ""
- tgt = ""
- arg = ""
- dir = empty
- desc = empty
- hk = empty
- icon = empty
- show = empty
- i = 0
- do while i < wscript.arguments.count
- s = wscript.arguments(i)
- if scf = "" then
- if left(s, 1) = "/" then
- s = ucase(mid(s, 2))
- if s = "DIR" then
- i = i + 1
- if i >= wscript.arguments.count then help
- dir = wscript.arguments(i)
- elseif s = "DESC" then
- i = i + 1
- if i >= wscript.arguments.count then help
- desc = wscript.arguments(i)
- elseif s = "HK" then
- i = i + 1
- if i >= wscript.arguments.count then help
- hk = wscript.arguments(i)
- elseif s = "ICON" then
- i = i + 1
- if i >= wscript.arguments.count then help
- icon = wscript.arguments(i)
- elseif s = "SHOW" then
- i = i + 1
- if i >= wscript.arguments.count then help
- show = wscript.arguments(i)
- else
- help
- end if
- else
- scf = s
- end if
- elseif tgt = "" then
- tgt = s
- else
- if (instr(s, " ") > 0) or (instr(s, "&") > 0) or (instr(s, "|") > 0) or (instr(s, ">") > 0) or (instr(s, "<") > 0) then s = """" & s & """"
- if arg = "" then
- arg = s
- else
- arg = arg & " " & s
- end if
- end if
- i = i + 1
- loop
- if (scf = "") or (tgt = "") then help
- set fs = createobject("scripting.filesystemobject")
- if fs.fileexists(tgt) then
- tgt = fs.getfile(tgt).path
- elseif fs.folderexists(tgt) then
- tgt = fs.getfolder(tgt).path
- end if
- set sc = createobject("wscript.shell").createshortcut(scf)
- sc.targetpath = tgt
- sc.arguments = arg
- if dir <> empty then sc.workingdirectory = dir
- if hk <> empty then sc.hotkey = hk
- if show <> empty then sc.windowstyle = show
- if desc <> empty then sc.description = desc
- if icon <> empty then sc.iconlocation = icon
- sc.save
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement