PDA

View Full Version : Delete shortcut in Startup



NewsArchive
09-15-2017, 03:30 AM
Hi,

I would like to have my script delete a previously created shortcut in
Startup.

And this is not to be done by uninstalling but by a later run of the
install based on a condition.

Is this possible ?

Cheers
/Poul

NewsArchive
09-15-2017, 08:28 AM
Hi Poul,

> I would like to have my script delete a previously created shortcut in
> Startup.
>
> And this is not to be done by uninstalling but by a later run of the
> install based on a condition.
>
> Is this possible ?

Absolutely no problem. A Shortcut is nothing more than a file with a .lnk
extension. Just use the "Delete File(s)..." script function.

Similar to this:

http://www.lindersoft.com/forums/showthread.php?24427-Removing-Shortcut-Icons&p=45551

Does this help?

Friedrich

NewsArchive
09-15-2017, 08:28 AM
Hi Friedrich,

Thanks very usefull.

BUT it turns out that this does not solve my problem in this case: If
I install a program on a terminal server and create a shortcut in
"Startup" it turns out that this now works for all users on the
terminal server.
Is it possible to create the Startup shortcut for the user running the
installation only ?

Cheers
/Poul

NewsArchive
09-15-2017, 08:29 AM
Hi Poul,

> Thanks very usefull.
>
> BUT it turns out that this does not solve my problem in this case: If I
> install a program on a terminal server and create a shortcut in "Startup"
> it turns out that this now works for all users on the terminal server.
> Is it possible to create the Startup shortcut for the user running the
> installation only ?

if you install elevated ("per-machine") then the current user is "all users"
<g> because you are accessing the administrator's profile when you launch
the setup.

You can only do "per-user" actions in Windows when you create a non-elevated
installer (please note that you do not have any access to protected areas in
this case). BTW, this is by Windows design and the expected behavior!

What you can do is to use a dirty trick. Create a separate helper
executable with SetupBuilder (e.g. a Blank Script). Set the elevation level
to "asInvoker". Then add the Delete File(s) script function to remove the
Shortcut. Compile the helper executable and add it to your main installer
(e.g. as a Support File). Call this helper application from your main
setup.exe -- but enable "Launch non-elevated under UAC". It will then run
under the current user profile.

BTW, if your first installer created that Shortcut then your update
installer can also remove it if both use installers the same execution
level.

Friedrich

NewsArchive
09-15-2017, 08:30 AM
You can request elevated rights for some function at runtime:

Create sudo.cmd with contense:
LinePrint('@echo Set objShell = CreateObject("Shell.Application") >
%temp%\sudo.tmp.vbs','sudo.cmd')
LinePrint('@echo args = Right("%*", (Len("%*") - Len("%1"))) >>
%temp%\sudo.tmp.vbs','sudo.cmd')
LinePrint('@echo objShell.ShellExecute "%1", args, "", "runas" >>
%temp%\sudo.tmp.vbs','sudo.cmd')
LinePrint('@cscript %temp%\sudo.tmp.vbs','sudo.cmd')



Create batch file with commands to execute
In my case, this registerd .Net COM
LinePrint('sudo cmd /c '&Clip(Loc:DotNetPath) &' '& Clip(Loc:ComDLL) & '
/register /codebase /tlb','comregister.bat')
LinePrint('exit','comregister.bat')

Allways place exit in the end, vb script can keep the window open.

Run your batch file.

Kzendra

--
It ain't the fall that kills you
It's the sudden stop at the bottom.

NewsArchive
09-15-2017, 08:31 AM
Thanks for the explanation Friedrich.
Will give it a go with a separate script.

Cheers
/Poul

NewsArchive
09-15-2017, 09:29 AM
Hi Friedrich,

I have now made the helper script. The only item in this is the
shortcut in Startup. The script has in General information > Generator >
Execution level = asInvoker.

In the main script I call the helper script like this:
Run Program
("%_SB_INSTALLDIR%\MariSoft\MobilService-automode.exe", "")
[Feature:Always Install] [Hide] [Non-Elevated]

But it still creates the Startup in common:
Startup Common Mobilservice
AutoMode.lnk C:\PStellar7\MariSoft\StartMserviceAutomode.bat

What am I missing here ?

Cheers
/Poul

NewsArchive
09-16-2017, 03:05 AM
Hi Poul,

did you set the helper app to per-user mode (add a "Set Installer Flag"
script function and use "$SB_ALLUSERSFLAG$" -- do not mark the "Set User"
checkbox).

Friedrich

NewsArchive
09-16-2017, 03:06 AM
Now I did and it now works great.
Thank you :-)

/Poul

NewsArchive
09-16-2017, 03:06 AM
> Now I did and it now works great.
> Thank you :-)

Perfect! Thanks for the good news, Poul :-)

Friedrich