Powershell Script is slow in opening an application

  powershell, windows

I have a PowerShell script that opens a file when you press a hotkey like: ctrl + alt + f so that the app automatically runs every time the user presses those key combinations.

Now, the problem is that it indeed opens the application/file, but it takes 4-5 second to process it. I want the process to be fast enough so that the script opens the desired files the moment the user presses the key combinations and not seconds after it. I don’t know what caused this slowdown…

Here’s the script:

# Get the Desktop dir. path.
$desktopDir = [Environment]::GetFolderPath('Desktop') 

# Create the shortcut object, initially in-memory only.
$shc = 
  (New-Object -ComObject 'Wscript.Shell').CreateShortcut("$desktopDirlinkthis.lnk") 

# Set the target executable (name will do if in $env:PATH).
$shc.TargetPath = 'C:UsersabhayDownloadsTestscript.py' 

# Assign the hotkey.
$shc.Hotkey = 'Ctrl+Alt+F'

$shc.Save()

(Code originally taken from this question asked by me earlier)

Source: Windows Questions

LEAVE A COMMENT