Copying shortcuts to the desktop - powershell

ALL,
I'm working on the program which installs itself in the user selected directory and then creates a shortcuts in the Start Menu for all users. The shortcuts are placed in the folder named by the following scheme:
<foo barx.y.z>
where "foo bar" is the name of the software and the "x.y.z" is the version number.
After installing we run the configuration scripts written in the PowerShell.
Its been decided that those shortcuts needs to be present on the user Desktop as well. So I thought that the easiest and the forward compatible solution would be to just copy those shortcuts at the end of the configuration scripts.
However, when I start the "Command Prompt" terminal inside Windows {7} and tried to do this:
copy "c:\ProgramData\Microsoft\Windows\Start Menu\foo *" c:\Users\igor
I got an error message saying that the system cannot find the file specified.
Can someone shed some light lights? What is the proper way of copying this stuff? Or since I will do it inside PowerShell script everything will be good?
Thank you.

Igor, you can try do something like this (maybe it help you):
copy "c:\ProgramData\Microsoft\Windows\Start Menu\Programs\*Hyper-V*" "c:\Users\$env:UserName" -Recurse -Force

Related

How to stop VScode creating a symlink instead of a file

I have tried to google, this can't find anything or on here so suspect i'm being a noob, so perhaps someone can educate me.
I am copying a file from one directory within by repo in VScode to another. It is a MAKEFILE (which i'm not that familiar with anyway).
I then select copy...
And then i select a sub directory within same directory so i can paste
Once i complete this, rather than the file being copied, it creates a syslink to the file which isn't what i want as i now need to modify the file...
Even if i create the file as a new file, this will still display as a symlink.
Am i doing something stupid here?
I have created the file through the command line but the file still shows as a symlink.
Driving me crazy, please help!
thanks :)
I found the solution here, just complete these steps:
Open VSCode and press Command+Shift+p
Type Uninstall and select option "Uninstall code command from PATH"
Input admin password and then close VSCode once it confirms its been removed
Close VScode application
Re-open VScode and press Command+Shift+p
Type "Install code command to PATH"
Input admin password
Try now and this should work.
I found if i didnt close VScode after removing/adding command to PATH, the setting was lost.
Hope this helps.

How to build AHK scripts automatically on startup?

Each time I restart my computer, I have to rebuild all my AHK Scripts so the keyboard shortcuts will work.
For instance, I have a script that assigns Ctrl+j to set up an instance of the MEAN stack and open my web site. After restarting my computer, pressing ^j does nothing until I go into Sublime and ^b (Build). I could build from AHK, but I do a lot of work in Sublime, so it's easier to build there.
How can my AHK Scripts automatically build on startup?
What I've tried so far:
Looking to build a post startup, startup script: This Is concerned with using an AHK script to start many programs on starup. I use Windows' Task Manager > Startup to do this, thus has nothing to do with making. I want to not have to rebuild all my scripts after every restart.
Windows 10 - run script on windows startup problem: This assumes the start script is already written and implemented. However, it doesn't appear to give the script.
AutoHotKey FAQ: I eventually found a solution here, but it took a long time to dig through the questions so I figured I'd post a question anyway to help others who run into this.
Simply add a shortcut (don't need to be the actual file) of your script in the Windows 'Startup' folder.
Three ways to get there:
1- In Windows Explorer, go to %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup (for current user startup list) or %ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Startup (for every user startup list)
or
2- Open Windows' Run application (Windows + r) write shell:startup (current user) or shell:common startup (every user) in the edit field and click on the 'ok' button.
or
3- Start > Programs > Startup (old Windows versions)
In AutoHotKey you can access this folder with the Built-in Variables %A_Startup% (current user) or %A_StartupCommon% (every user)
To create the (current user) shortcut automatically from your script, use the following line:
FileCreateShortcut, %A_ScriptFullPath%, %A_Startup%\shortcutname.lnk
To do the same for all users, use this line instead:
FileCreateShortcut, %A_ScriptFullPath%, %A_StartupCommon%\shortcutname.lnk
(in the case of having a file with the same name in the folder, the file would be overwritten)
ps: Win10 blocks scripts in startup with AHK running as admin... read the comments of this post for extra info.
Run at startup in Windows 10:
Compile the script to *.exe
Put the shortcut of that exe in startup folder "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup"
That's all. Do NOT set it to run as admin. Programs in Win10 don't run at startup which are marked as run as admin.
Run Script as admin at Startup in Windows 10:
Go to ahk script and mark it run as admin.
Create the VBScript using a text editor
'put it in startup folder to run the mentioned ahk script at startup
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run """C:\Users\jerry\Downloads\scripts\some_script.ahk""", 0 'Must quote command if it has spaces; must escape quotes
Set WshShell = Nothing
Replace C:\Users\jerry\Downloads\scripts\some_script.ahk with the path to your script with extension and save it as .vbs.
Place this .vbs script at startup folder %appdata%\Microsoft\Windows\Start Menu\Programs\Startup
PS: My fav AHK scripts: https://gourav.io/blog/autohotkey-scripts-windows
Open note pad or any other text editor
write Start "" "C:\ahk\yourdirectory\yourahk.ahk"
press save as
navigate to %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
name the filename anything.bat
As a Windows 7 user, I have limited experience with Windows 10. I have heard that W10 can be finicky with regard to running programs underground administratie or limited user. In W7, you just add the .AHK file link to the startup dir.
A simple solution without writing any code, using the Windows Task Scheduler, set the script to start when the user logs on. If it is set to system startup it will error because it is too early.
To allow the script to automate administrative programs without running as admin, here're the required steps:
When installing AHK, check the "Add 'Run with UI Access' to context menus" option.
After installation, find AutoHotkeyU64_UIA.exe on your disk.
Open the .ahk script's properties, change the "Open with" option to the AutoHotkeyU64_UIA.exe you just found.
Create a shortcut to this script.
Open %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup in the file explorer.
Move that shortcut to this folder.
And you're done.
How does it work?
The "Add 'Run with UI Access' to context menus" option provides a workaround for common UAC-related issues by allowing the script to automate administrative programs without running as admin.
Reference: Run with UI Access.
Open windows run (win+r) and type “shelll:startup”
Copy paste the ahk file into there
Close the folder
And that‘s all!

Install VSCode in a specific folder

I just downloaded the Visual Studio Code App from https://code.visualstudio.com/ and when I tried to install it, it simply just installed it by itself, without the option to change the installation path.
I have an external harddrive, which is where I want the IDE to be placed instead of the Local Harddrive. How can I change this?
On the VSCode download page select "System Installer" instead of "User Installer". The System installer will prompt you for the install location.
Full credit to Hans Passant for giving the following working solution as a comment.
The installer does very little beyond copying the files, it just creates some Explorer context menu shortcuts ("Open with Code"). Otherwise following Chromium conventions and copying itself to c:\Users\yourname\AppData\Local\Code\app-0.1.0 so it can update itself without you noticing. Boo. So high odds that simply moving that folder to the other drive works just fine, put it anywhere and create a shortcut to Code.exe. If you still want the context menu entry to work then use Regedit and search for "code\app-0.1.0".

QuickText in notepad++ not saving code snippets!

I installed notepad++ on Windows7. I installed QuickText into notepad++. I add my custom snippets into QuickText and while notepad is open, the snippets work fine. As soon as I close notepad and open it again, the snippets are gone. Has anyone else had this problem, it should be an easy fix? They are not persisting or sticking.
Anyone know how to fix this? Any ideas?
Haven't used Quicktext but it looks like it is no longer under development.
From what I can tell FingerText is similar, and hopefully should be able to do what you are after.
The complete answer lies in a combination of Nick's and Jrod's answers.
If you create the a Config folder in the C:\Program Files\Notepad++\plugins\ (or C:\Program Files (x86)\Notepad++\plugins\ if you installed it to that folder) and then place the QuickText.ini file within that folder you will notice many default "snippits" show up.
Now in order for you to save your "snippits" if you are in Windows 7 or Vista (which will save to the QuickText.ini file) you must run Notepad++ as Administrator.
As a side note the snippits save fine with in Linux if you install Notepad++ through Wine.
This issue is caused by administrative privileges. You need to run notepad++ as an administrator or it will fail silently.
You must copy QuickText.ini to folder c:\Program Files\Notepad++\plugins\Config\ (I created this folder itself)
This page help me
Sorry for my badly english. Your problem is in inslall. Correct install:
Copy to folder plugins all files except one (quicktext.ini).
In such directory create new folder config.
Copy quicktext.ini into it.
After such installation snippets works correctly.

I have made an installer for MyProgram but the uninstall shortcut that it creates leaves behind empty folders

I have created an installer for MyProgram using the Visual Studio Installer (Visual Studio Setup Project). It is called "MyProgram Setup.msi". It installs the program fine and if it is uninstalled using the Add/Remove Programs control panel then everything gets removed as it should.
The problem is that I want to add a shortcut to the "User's Programs Menu" under the program shortcut called "Uninstall MyProgram". I have tried doing this in 3 different ways and in all 3 ways if MyProgram is uninstalled using that shortcut, the uninstall will leave behind 2 empty folders ("...Program Files\MyCompany\" and "...Program Files\MyCompany\MyProgram\").
Here are the 3 ways that I have tried to make an uninstaller shortcut:
1) A shortcut to a batch or script file
Uninstall MyProgram.bat:
#ECHO OFF
msiexec /uninstall {MyGUID}
Uninstall MyProgram.vbs:
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("START /B msiexec /uninstall {MyGUID}")
Set objShell = Nothing
2) Editing the MSI file using Orca.exe
I found out how to do this using this guide: http://www.codeproject.com/KB/install/MSIShortcuts.aspx
I added the Shortcut Entry to the Shortcut table. Uninstalling worked but it still left behind the 2 empty folders when using this shortcut.
3) From code within MyProgram.exe
I modified MyProgram.exe to take a "/uninstall" command line parameter to run "msiexec.exe /uninstall {MyGUID}" and exit itself. Similar to this solution: http://www.codeproject.com/KB/install/DeployUninstall.aspx
None of these attempts created a shortcut which can uninstall the program as well as the program's base folders. I don't want to switch to some other installer product such as Inno Setup, NSIS, or WiX.
If for whatever reason manually running msiexec /x {MyGUID} doesn't remove all folders, then it's an issue with your setup or something you're doing in your application.
For more information about creating an uninstall shortcut with WiX, check out this blog post which goes into quite a bit of detail. Based on the information shown in the blog post you should be able to work out how to stick with your existing technology and use some variation on the (2) method you mention.
It seems that this is a bug in the Visual Studio Installer. I have decided to use WiX instead. It is able to create the uninstall shortcut with correct functionality.