mIRC Home    About    Download    Register    News    Help

Print Thread
#210211 08/03/09 05:59 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Someone that have an idea on how to make shortcut's to windows start menu true mirc? i don't know how to do this? i want to be able to make a shortcut true my script, you aren't allowed to include mirc.exe with the script, but i have a uninstaller added to the shortcut folde in windows start menu, so then i want mirc it self to end up there too..


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
sparta #210224 09/03/09 12:40 AM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
alias createshortcut {
  if ($0 != 2) || ($lock(com)) return
  var %obj = createshortcut $+ $ticks, %obj2 = %obj $+ 1, %startmenu, %result
  .comopen %obj wscript.shell
  if (!$comerr) {
    noop $com(%obj,specialfolders,3,bstr,startmenu)
    if ($com(%obj).result) %startmenu = $v1
    else return $false
    noop $com(%obj,createshortcut,3,bstr,$+(%startmenu,\programs\,$mkfn($nopath($1)),.lnk),dispatch* %obj2)
    if (!$comerr) {
      noop $com(%obj2,targetpath,4,bstr,$noqt($1)) $com(%obj2,windowstyle,4,int,1) $&
        $com(%obj2,description,4,bstr,$2) $com(%obj2,workingdirectory,4,bstr,$nofile($1))
      %result = $iif($com(%obj2,save,1),$true,$false)
      .comclose %obj2
    }
    else %result = $false 
    .comclose %obj
  }
  else %result = $false
  return %result
}


$createshortcut(<file>,<description>) - returns $true for success, $false for failure and $null if COM is locked or you supplied an incorrect number of arguments.

hixxy #210234 09/03/09 07:01 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Thank you smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
hixxy #210236 09/03/09 12:37 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
There's a tiny mistake in that code which means occasionally one of the COM objects won't be closed. Use this one instead:

Code:
alias createshortcut {
  if ($0 != 2) || ($lock(com)) return
  var %obj = createshortcut $+ $ticks, %obj2 = %obj $+ 1, %startmenu, %result
  .comopen %obj wscript.shell
  if (!$comerr) {
    noop $com(%obj,specialfolders,3,bstr,startmenu)
    if ($com(%obj).result) %startmenu = $v1
    else %result = $false
    noop $com(%obj,createshortcut,3,bstr,$+(%startmenu,\programs\,$mkfn($nopath($1)),.lnk),dispatch* %obj2)
    if (!$comerr) {
      noop $com(%obj2,targetpath,4,bstr,$noqt($1)) $com(%obj2,windowstyle,4,int,1) $&
        $com(%obj2,description,4,bstr,$2) $com(%obj2,workingdirectory,4,bstr,$nofile($1))
      %result = $iif($com(%obj2,save,1),$true,$false)
      .comclose %obj2
    }
    else %result = $false 
    .comclose %obj
  }
  else %result = $false
  return %result
}


np smile

hixxy #210239 09/03/09 02:08 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I get a empty shortcut, it don't have any target or icon, and the only way i can get this is if i remove the line:

if ($0 != 2) || ($lock(com)) return

so i used a ; to skip it, if that file remain nothing happens, and if i do: //echo -a $lock(com) i get the answer $false to it's not locked, so dunno what i doing wrong, if i understand your code right it should be used:

/createshortcut mirc.exe

or do i miss understand it?


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
sparta #210250 09/03/09 06:04 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
It's supposed to be used as an identifier like this:

Code:
//echo -a $createshortcut($mircexe,Run mIRC!)


The first parameter is the file (this must be the FULL path - "c:\program files\mirc\mirc.exe" not just "mirc.exe") and the second parameter is the description you want to appear when you hover over the shortcut. $mircexe will return the full path to the mIRC executable - so use that instead of mirc.exe

Use the code exactly as I gave it to you, just make sure you use it as an $identifier and not a /command.

hixxy #210251 09/03/09 06:16 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
i try it.. thnx again smile

;------- Working

Is it possible to put the file in any other folder then Program? want it to be stored in "mIRC" or something similar, tested to just add a new folder to the start menu, but i get false from the script, also tested to make my install create the shortcut folder, still same result

Last edited by sparta; 09/03/09 06:33 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
sparta #210271 09/03/09 11:38 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
alias createshortcut {
  if ($0 != 3) || ($lock(com)) return
  var %obj = createshortcut $+ $ticks, %obj2 = %obj $+ 1, %startmenu, %result, %path, %i = 1, %depth
  .comopen %obj wscript.shell
  if (!$comerr) {
    noop $com(%obj,specialfolders,3,bstr,startmenu)
    if ($com(%obj).result) %startmenu = $v1
    else %result = $false
    %path = $+(%startmenu,\,$1\)
    %depth = $numtok(%path,92)
    if (!$isdir(%path)) {
      while (%i <= %depth) {
        if (!$isdir($gettok(%path,1- $+ %i,92))) .mkdir $qt($gettok(%path,1- $+ %i,92))
        inc %i
      }
    }
    noop $com(%obj,createshortcut,3,bstr,$+(%path,$mkfn($nopath($2)),.lnk),dispatch* %obj2)
    if (!$comerr) {
      noop $com(%obj2,targetpath,4,bstr,$noqt($2)) $com(%obj2,windowstyle,4,int,1) $&
        $com(%obj2,description,4,bstr,$3) $com(%obj2,workingdirectory,4,bstr,$nofile($2))
      %result = $iif($com(%obj2,save,1),$true,$false)
      .comclose %obj2
    }
    else %result = $false 
    .comclose %obj
  }
  else %result = $false
  return %result
}


This one supports start menu folders as well.

The syntax has changed now as you have to specify the folder you want the shortcut to appear in.

The new syntax is:

$createshortcut(<folder>,<file>,<description>) - 2nd and 3rd parameters are the same as they were before.

The <folder> parameter supports multiple depths, so you can do this:

Code:
//echo -a $createshortcut(programs\mIRC,$mircexe,Run mIRC!)


This will create a mIRC folder inside the programs menu and place the shortcut inside of that folder.

You can go even deeper if you like and do something like this:

Code:
//echo -a $createshortcut(programs\mIRC\mIRC2\mIRC3\mIRC4\You can go as deep as you like,$mircexe,Run mIRC!)


If you want anything else adding let me know smile

hixxy #210275 10/03/09 06:24 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Thank you, just one more thing, the installer i use creating a file called "irunin.ini", and it is located in the script dir, this is the uninstaller for the script, and it store the shortcut folder in that file "path to it", how would i return the path from a variable that looks like: %SCFOLDERTITLE%= ?

example of the ini file:

[Config]
%SCFOLDERPATH%=C:\Documents and Settings\All Users\Start Menu\Programs\My Shortcut Folder
%SCFOLDERTITLE%=My Shortcut Folder

$readini(irunin.ini,Config,%SCFOLDERTITLE%) <- will not work, and the %SCFOLDERPATH% can be changed so it looks like:

C:\Documents and Settings\My Users\Start Menu\Programs\My Shortcut Folder

Tested with $eval() but no luck, any other way to return the value from the file?

The reason why i need to return the value is that when my script is installed, then mirc.exe will be copied (with your code) to the shortcut folder made during the install, the user are able to change the name of it so it's not the same name all the time. Thnx in advance smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
sparta #210285 10/03/09 04:45 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
$readini(irunin.ini,Config,% $+ SCFOLDERTITLE%) should work fine.

hixxy #210286 10/03/09 05:06 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline OP
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Nope, * /echo: insufficient parameters . the same as i get when i have been trying different codes.. smirk and the file is located in the mirc folder so should work..

;---- Edit

Did try //echo -a -> $isfile(irunin.ini) , and it return $true

;------ Edit again

Solved it, needed to use $readini(file,n,% $+ var%)

;----- Edit once more.

Any idea why this won't work?
Code:
alias createshortcut {
  .echo -q $createshortcut1($mircexe,Run mIRC!)
}
alias startmenupth {
  return $+($readini(irunin.ini,n,Config,% $+ SCFOLDERTITLE%),$chr(92))
}
alias createshortcut1 {
  if ($0 != 2) || ($lock(com)) return
  var %obj = createshortcut $+ $ticks, %obj2 = %obj $+ 1, %startmenu, %result
  .comopen %obj wscript.shell
  if (!$comerr) {
    noop $com(%obj,specialfolders,3,bstr,startmenu)
    if ($com(%obj).result) %startmenu = $v1
    else %result = $false
    noop $com(%obj,createshortcut,3,bstr,$+(%startmenu,\programs\, $startmenupth ,$mkfn($nopath($1)),.lnk),dispatch* %obj2)
    if (!$comerr) {
      noop $com(%obj2,targetpath,4,bstr,$noqt($1)) $com(%obj2,windowstyle,4,int,1) $&
        $com(%obj2,description,4,bstr,$2) $com(%obj2,workingdirectory,4,bstr,$nofile($1))
      %result = $iif($com(%obj2,save,1),$true,$false)
      .comclose %obj2
    }
    else %result = $false 
    .comclose %obj
  }
  else %result = $false
  return %result
}

as soon as i try change the path it wont work, but do i type out the path instead of calling my alias it working, but the alias return the same as when i type. I also tryed to add the readini instead of the alias, but the same result, and if it create a shortcut ends up in the startmenu\program ..

Last edited by sparta; 10/03/09 06:42 PM.

if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
sparta #210339 11/03/09 11:17 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
You're not using the newest version of my $createshortcut alias.. look up again, I made a version for you where you can specify a folder for the shortcut to be in.


Link Copied to Clipboard