Jump to content











Photo
- - - - -

[script] Desktop shortcuts script


  • Please log in to reply
27 replies to this topic

#1 Ove

Ove

    .script developer

  • .script developer
  • 192 posts
  • Location:Fagaras, Romania
  •  
    Romania

Posted 04 August 2006 - 03:10 PM

I have been working on a way to create desktop shortcuts in Windows PE.
Here it is:

It uses an AutoIT script that runs after Explorer and creates the shortcuts, and refreshes the desktop.
It looks for a file called "shortcut.inf" in i386\system32. It reads what shortcuts are to be created from there.

The syntax of the shortcut.inf file is this:
On each line, there is a string like this:
nr,str1,str2

nr is: 1 for creating a shortcut, and 2 for creating a folder
str1 is the source exe for the shortcut, or the name of the folder to be created
str2 is the destination of the shortcut (it is not used if creating a folder)

There are 4 "!" commands
!DE - the desktop folder
!WD - the WinDir (X:\I386)
!SM - the path to start\programs
!PE - the PE Drive (X:)

Examples:
This line makes a shortcut to cmd.exe on the desktop:
1,!WD\system32\cmd.exe,!DE\Command Prompt

These 2 lines create a folder on the desktop, and places a shortcut of cmd.exe there
2,!DE\Tools
1,!WD\system32\cmd.exe,!DE\Tools\Command Prompt

To better illustrate this, I have modified the taskman and regedit scripts to add shortcuts. They are attached here also.

Known problems:
You CAN make shortcuts in the start menu using this tool, BUT Explorer does NOT refresh automatically (don't know why, working on it...). So the shortcuts get created, but start\programs shows (empty). If anyone knows how to make Explorer refresh automatically, PLEASE let me know

Problems, bugs, suggestions, post them here.

#2 Yorn

Yorn

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:United States

Posted 04 August 2006 - 05:59 PM

Known problems:
You CAN make shortcuts in the start menu using this tool, BUT Explorer does NOT refresh automatically (don't know why, working on it...). So the shortcuts get created, but start\programs shows (empty). If anyone knows how to make Explorer refresh automatically, PLEASE let me know


You could maybe kill Explorer and then reload it with an AutoIt script? I know it's not a good solution, and it wouldn't be a permanent fix, but it might work.

#3 Yorn

Yorn

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:United States

Posted 04 August 2006 - 07:10 PM

I just tested this and it's really slick. Since psc fixed the mousclass.sys issue, all the builds I test have been working as far as I can tell. Thanks guys!

#4 Brito

Brito

    Platinum Member

  • .script developer
  • 10616 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 04 August 2006 - 07:41 PM

Great work Ove!! :P

Sorry for not giving feedback for these new scripts yet, I'm still working on 049, but I'll be giving news as soon as I start adding them in the next release..

Keep it up! :P

#5 xpdoctor

xpdoctor

    Newbie

  • Members
  • 11 posts

Posted 05 August 2006 - 04:31 PM

You could maybe kill Explorer and then reload it with an AutoIt script? I know it's not a good solution, and it wouldn't be a permanent fix, but it might work.


I don't think that killing explorer is a good solution because its the shell and this will make the pc to restart

#6 Ove

Ove

    .script developer

  • .script developer
  • 192 posts
  • Location:Fagaras, Romania
  •  
    Romania

Posted 06 August 2006 - 06:18 PM

I have been mistaking...
It's not the refresh problem that's the cause of the start menu not working...
It was 2 registry keys.
Start menu shortcuts will work if you use my new explorer script (v 005)

But the refresh problem still persists.
I'll see if it can be fixed

#7 Yorn

Yorn

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:United States

Posted 07 August 2006 - 01:40 PM

How about nircmd? It can make shortcuts, but I don't know if you can reverse-engineer it or just use it? It's free:
http://www.nirsoft.n...ils/nircmd.html

Creates a shortcut to Windows Calculator:
nircmd.exe shortcut "f:\winnt\system32\calc.exe" "~$folder.programs$\Calculators" "Windows Calculator"

Haven't tested using nircmd directly in a .SCRIPT, but it's got some pretty nice scripting features.

There's actually a TON of NirSoft utilities and such that are freeware that are great tools for probably any PE build listed here:
http://www.nirsoft.n...tils/index.html

One of them, NirExt, is about 38 kb in size and adds the ability to make custom shortcuts, custom folders, and an "advanced run" feature so you can pass arguments to a commandline app from GUI:
http://www.nirsoft.n...ils/nirext.html

#8 TheHive

TheHive

    Platinum Member

  • .script developer
  • 4199 posts

Posted 07 August 2006 - 04:13 PM

Posted Image

Posted Image

#9 Yorn

Yorn

    Frequent Member

  • Advanced user
  • 178 posts
  • Location:United States

Posted 07 August 2006 - 04:20 PM

Awesome. So I take it the new shortcuts script did work and didn't need anything fancy?

#10 TheHive

TheHive

    Platinum Member

  • .script developer
  • 4199 posts

Posted 07 August 2006 - 06:32 PM

Yes as you posted. I just downloaded all three and placed them in the
\Projects\Standard\Tweaks

I let it Replace any scripts that where there.

#11 TheHive

TheHive

    Platinum Member

  • .script developer
  • 4199 posts

Posted 07 August 2006 - 06:37 PM

Question:
Which of the above Scripts actually makes the Shortcuts.
And how could a person include there own. For developers.

What I was thinking is that the shortcut.script.zip is the one that handles the shortcut creation and is needed to create them. And the actual command to create what shortcuts are within the
Taskman.script.zip and regedit.script.zip themselves.

If the creation of the shortcuts are withing the Taskman.script.zip and regedit.script.zip then it would be best to have the user have the choice to create a Desktop, Start Menu, Quicklaunch Shortcut or any other options I have forgotten. Instead of just forcing shortcuts on the user. Similiar to the tick item options within present scripts.

#12 Ove

Ove

    .script developer

  • .script developer
  • 192 posts
  • Location:Fagaras, Romania
  •  
    Romania

Posted 08 August 2006 - 11:52 AM

the shc.exe actually creates the shortcuts when entering WinPE
the command to create what shortcuts are in the taskman and regedit scripts

To make taskman create a shortcut, you need to add these 2 lines in the script:
If,NotExistFile,"%TargetDir%\i386\system32\shortcut.inf",FileCreateBlank,"%TargetDir%\i386\system32\shortcut.inf"

TXTAddLine,"%TargetDir%\i386\system32\shortcut.inf","1,!WD\system32\taskmgr.exe,!DE\Windows Task Manager","Append"

TXTAddLine,"%TargetDir%\i386\system32\shortcut.inf","1,!WD\system32\taskmgr.exe,!SM\Windows Task Manager","Append"


#13 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 18 August 2006 - 10:55 AM

In my installation (XP German) the shortcut works mit desktop but not with start menu.
I have a directory "B:\ProfilesDir\Default User\Start Menu\Programs" which contains the shortcuts.
But when I click Start > Programme I get the submenu "Leer" (means empty)

Maybe there is another question of internalization. :P

Peter

#14 smiley

smiley

    Silver Member

  • .script developer
  • 905 posts
  •  
    Greece

Posted 18 August 2006 - 12:19 PM

In my installation (XP German) the shortcut works mit desktop but not with start menu.
I have a directory "B:\ProfilesDir\Default User\Start Menu\Programs" which contains the shortcuts.
But when I click Start > Programme I get the submenu "Leer" (means empty)

Maybe there is another question of internalization.

Peter


I had the same problems with you but this was solved when a made this script to fix the wrong paths in profiles folder

#15 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 18 August 2006 - 01:02 PM

I had the same problems with you but this was solved when a made this script to fix the wrong paths in profiles folder


That was just what I thought.
When building my Localization script I found that in any HIVE???.INF file.
I'll include it into my Localization script.

Peter

#16 Holger

Holger

    Silver Member

  • .script developer
  • 534 posts
  • Location:Munich
  • Interests:- programming / scripting
    - scooter driving / modifying
    - writing poems
  •  
    Germany

Posted 31 August 2006 - 03:11 PM

Small suggestion:
Change the line-split-character in the script to "|" so we can also commandline parameters which includes a ",", like i.e. "explorer.exe /e,%ramdrv%"
Also to specify the icon number is sometimes good.
The new "shortcut.inf" would look like:
1|!WD\explorer.exe|!DE\Explorer|/e,%RAMDRV%\|4
So it will create a link "Explorer.lnk" on the desktop with the parameters "/e,%RAMDRV%" and the icon number 4.

And maybe for future use you could implement the Quicklaunch-folder like:
...

$pedrive=StringLeft($windir,1)&":";detect PEdrive

-> $qlaunch=@AppDataDir&"\Microsoft\Internet Explorer\Quick Launch"

-> If Not FileExists($qlaunch) Then DirCreate($qlaunch); should created before using

Opt("WinTitleMatchMode",4)

...

	$line=StringReplace($line,"!DE",$deskt);replace !DE with Desktop

->	$line=StringReplace($line,"!QL",$qlaunch);replace !DE with QuickLaunch

	$arr=StringSplit($line,"|");split the 2 - 4 parts of the line into an array

...
What do you think?
Thanks :P
Holger

#17 Holger

Holger

    Silver Member

  • .script developer
  • 534 posts
  • Location:Munich
  • Interests:- programming / scripting
    - scooter driving / modifying
    - writing poems
  •  
    Germany

Posted 31 August 2006 - 03:29 PM

Another idea: to not break other and 'old' scripts we could also use a special-character for "," like "#$c" like in "WinBuilder" :P

#18 smiley

smiley

    Silver Member

  • .script developer
  • 905 posts
  •  
    Greece

Posted 31 August 2006 - 03:34 PM

Another idea: If the path of a shortcut doesn't exist, the shortcut will not be created. Can you make the prog to create the folder before it creates the shortcut?

#19 Holger

Holger

    Silver Member

  • .script developer
  • 534 posts
  • Location:Munich
  • Interests:- programming / scripting
    - scooter driving / modifying
    - writing poems
  •  
    Germany

Posted 31 August 2006 - 03:48 PM

@smiley: this should be already possible.
Just create at first the folder and after that the shortcut, like:
...

2,%UserProfile%\Desktop\Tools

1,!WD\system32\notepad.exe,!DE\Tools\Notepad

2,%UserProfile%\Start Menu\Tools

1,!WD\system32\notepad.exe,!SM\Tools\Notepad

...

Hmmm...ok, with environment variables it doesn't work this way...

Edit: I think we should the "Autoit3.exe" update to the new version "3.2.0.1" cause this allows you to expand also filereading-strings with "Opt("ExpandEnvStrings",1)" which does not function like this in the old "3.1.1"-version.

#20 smiley

smiley

    Silver Member

  • .script developer
  • 905 posts
  •  
    Greece

Posted 31 August 2006 - 04:16 PM

@smiley: this should be already possible.
Just create at first the folder and after that the shortcut, like:

...

2,%UserProfile%\Desktop\Tools

1,!WD\system32\notepad.exe,!DE\Tools\Notepad

2,%UserProfile%\Start Menu\Tools

1,!WD\system32\notepad.exe,!SM\Tools\Notepad

...

Hmmm...ok, with environment variables it doesn't work this way...

Edit: I think we should the "Autoit3.exe" update to the new version "3.2.0.1" cause this allows you to expand also filereading-strings with "Opt("ExpandEnvStrings",1)" which does not function like this in the old "3.1.1"-version.




why not doing this:
...

2,!DE\Tools

1,!WD\system32\notepad.exe,!DE\Tools\Notepad

2,!SM\Tools

1,!WD\system32\notepad.exe,!SM\Tools\Notepad

...


#21 Holger

Holger

    Silver Member

  • .script developer
  • 534 posts
  • Location:Munich
  • Interests:- programming / scripting
    - scooter driving / modifying
    - writing poems
  •  
    Germany

Posted 31 August 2006 - 04:25 PM

You're right :P

#22 Holger

Holger

    Silver Member

  • .script developer
  • 534 posts
  • Location:Munich
  • Interests:- programming / scripting
    - scooter driving / modifying
    - writing poems
  •  
    Germany

Posted 01 September 2006 - 01:56 PM

Forget it with the "QuickLaunch" so far.
That is very difficult to manage.
There are some API-commands I tried to save/create and restore the quicklaunch-toolbar - no luck :P
However, I changed the "shc.au3"-script so far that you can use also a comma and a different iconfile/iconnumber (not so difficult you know :P )
#notrayicon

$file=FileOpen ( @WindowsDir&"\system32\shortcut.inf", 0);open the file

If($file=-1)Then Exit;if it does not exist, exit

$windir=@WindowsDir;detect WinDir

$smprog=@ProgramsDir;detect Start\programs

$deskt=@DesktopDir;detect desktopdir

$pedrive=StringLeft($windir,1)&":";detect PEdrive

Opt("WinTitleMatchMode",4)

WinWait("classname=Shell_TrayWnd");wait until the taskbar appears

While(1)

	$line=FileReadLine($file);read a line from the file

	If(@error=-1)Then ExitLoop;if end of file, then exit

	$line=StringReplace($line,"!WD",$windir);replace !WD with WinDir

	$line=StringReplace($line,"!SM",$smprog);replace !SM with Start\programs

	$line=StringReplace($line,"!PE",$pedrive);replace !PE with PEDrive

	$line=StringReplace($line,"!DE",$deskt);replace !DE with Desktop

	$arr=StringSplit($line,",");split the 2 - 6 parts of the line into an array

	If $arr[1]=1 Then

		$param=""

		$iconfile=""

		$icon=0

		If $arr[0]>=4 Then $param=$arr[4]

		If StringInStr($param,"|") Then $param=StringReplace($param,"|",",")

		If $arr[0]>=5 Then $iconfile=$arr[5]

		If $iconfile="" Then $iconfile=$arr[2]

		If $arr[0]>=6 Then $icon=$arr[6]

		FileCreateShortcut($arr[2],$arr[3],"",$param,"",$iconfile,"",$icon);if line says to create a shortcut, create it

	EndIf

	If $arr[1]=2 Then DirCreate($arr[2]);if line says to make a dir, make it

WEnd

FileClose($file);close the file

WinActivate("classname=Progman");set focus to the desktop

Send("{F5}");refresh the desktop

The shortcut.inf could then look like:
1,!WD\system32\notepad.exe,!DE\Notepad

1,!WD\system32\notepad.exe,!SM\Notepad

1,!WD\system32\regedit.exe,!DE\Windows Registry Editor

1,!WD\system32\regedit.exe,!SM\Windows Registry Editor

1,!WD\system32\taskmgr.exe,!DE\Windows Task Manager

1,!WD\system32\taskmgr.exe,!SM\Windows Task Manager

1,!WD\explorer.exe,!DE\Explorer,/e|%RAMDRV%\,%SystemRoot%\system32\shell32.dll,45

1,!WD\system32\notepad.exe,!QL\Editor

One scriptline should then looks like:
TXTAddLine,"%TargetDir%\i386\system32\shortcut.inf","1,!WD\explorer.exe,!DE\Explorer,/e|%RAMDRV%\,shell32.dll,45","Append"
Thisone creates a shortcut to "%WindowsDir%\Explorer.exe" with name "Explorer", the cmdline argument "/e,%RAMDRV%\" with the icon "45" from the "shell32.dll".
Edit: forgot that it is not easy to write "#$c" to a txtfile - changed it to "|".
So long :P

#23 Ove

Ove

    .script developer

  • .script developer
  • 192 posts
  • Location:Fagaras, Romania
  •  
    Romania

Posted 03 September 2006 - 03:23 PM

I'll take into consideration all these suggestions in the next version
Good work everybody!

QuickLaunch doesn't work yet beacause of resource limitations.
When it does, I'll add QuickLaunch support

#24 smiley

smiley

    Silver Member

  • .script developer
  • 905 posts
  •  
    Greece

Posted 03 September 2006 - 03:26 PM

Holger has already removed the resource limitatin with his misc settings script

#25 Ove

Ove

    .script developer

  • .script developer
  • 192 posts
  • Location:Fagaras, Romania
  •  
    Romania

Posted 05 September 2006 - 06:30 PM

Forget it with the "QuickLaunch" so far.
That is very difficult to manage.

Yeah, it's difficult to manage
That's why I couldn't rest until I got it to work.

QuickLaunch works.
You can create shortcuts with parameters(even commas), icons, hotkeys, initial states(norm,min,max), working directories in QuickLaunch too (!QL)
And Windows Picture and fax viewer works

All in my new scripts
Get them at ove.boot-land.net




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users