I want to use scripts to create shortcuts under the Windows operating system (.lnk).
In the Windows environment, I chose PowerShell, wrote the script, successfully created .lnk.
$shell = New-Object -ComObject WScript.Shell
$desktop = [System.Environment]::GetFolderPath('Desktop')
$shortcut = $shell.CreateShortcut("$desktop\clickme.lnk")
$shortcut.TargetPath = "C:\Users\scc\Desktop\linkfolder"
$shortcut.IconLocation = "shell32.dll,004"
$shortcut.Save()
But my online running environment is Linux.
Fortunately, I found that PowerShell in 2016 on a multi-platform transplant, yes, it can support Linux. I found it, downloaded, and installed. Under Linux, in the PowerShell command window I can run some basic commands.
There was a run-time error!
When I run the first line of code:
$shell = New-Object -ComObject WScript.Shell
The error message is:
New-Object : Unable to load DLL 'api-ms-win-core-com-l1-1-0.dll': The specified
module or one of its dependencies could not be found.
(Exception from HRESULT: 0x8007007E)
At line:1 char:10
+ $shell = New-Object -ComObject WScript.Shell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-Object], DllNotFoundException
+ FullyQualifiedErrorId : System.DllNotFoundException,Microsoft.PowerShell.Commands.NewObjectCommand
According to the prompt, it seems that the lack of WScript-related modules. Missing DLL file.
My requirement is to run Java programs under Linux to create shortcuts in Windows format. (Stored in the network disk, the file system for the btrfs, and can provide SMB \ AFP \ NFS \ FTP these file services)
Yes, this demand seems to be strange, if you have a new solution ideas and ideas, please tell me or discuss with me.
I have a bold idea: can I use the SMB protocol to create an .lnk file?
You can use the below to create Windows Shortcuts in Linux:
MSLink
It is having both bash version and C source.
Refer this also:
Produce-lnk-file-on-gnu-linux-to-transfer-to-windows
Related
I'm on Powershell 5.1 which IIRC supports ThreadJob OOB.
I have a script which uses the module which used to work without issues.
Now I'm getting the following error:
ForEach-Object : The term 'Start-ThreadJob' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
Admittedly I haven't run the script (or used ThreadJob) in a while, but I get the "not recognized" error even when I just call Start-ThreadJob from the terminal.
I've rebooted and run DISM and sfc which didn't find any issues.
This is on a fairly fresh Windows 10 install.
Am I forgetting something?
I vaguely recall experiencing something like this a long time ago, but don't remember how I got around it.
Windows PowerShell - the legacy, Windows-only, ships-with-Windows edition of PowerShell whose latest and last version is 5.1.x - does not come with the ThreadJob module that provides the Start-ThreadJob cmdlet - only the modern, cross-platform, install-on-demand PowerShell (Core) edition (v6+) does.
However, you can install the module on demand in Windows PowerShell, from the PowerShell Gallery, with Install-Module -Scope CurrentUser ThreadJob, for instance.
The following cross-edition idiom installs the module on demand when running in Windows PowerShell, in the scope of the current user:
if ($PSVersionTable.PSVersion -lt 6 -and -not (Get-Command -ErrorAction Ignore -Type Cmdlet Start-ThreadJob)) {
Write-Verbose "Installing module 'ThreadJob' on demand..."
Install-Module -ErrorAction Stop -Scope CurrentUser ThreadJob
}
# Getting here means that Start-ThreadJob is now available.
Get-Command -Type Cmdlet Start-ThreadJob
Need to run build script in both the environment (windows and Linux).Build script is pointing to the powershell.exe path in window environment and working fine. But at the same time, same build script is not getting the powershell path and throwing error.
Executing task in folder root: PowerShell /home/userName/FolderName/Assetmonitor/scripts/build/client/build-client-dev.ps1 <
The terminal process failed to launch: Path to shell executable "PowerShell" does not exist.
It sounds like your script is trying to call the PowerShell executable, but "powershell" (technically powershell.exe) only exists on Windows and is the executable for powershell 5.x and earlier. The executable for PowerShell 7, which is the only version I'm familiar with that's available on Linux, is named "pwsh"(pwsh.exe on Windows).
I would recommend either: 1) installing PowerShell 7 on your Windows boxes and changing the script to call for pwsh instead of "PowerShell" (remember that Linux is case-sensitive), or 2) creating a symbolic link to somewhere in your existing $PATH environment variable (like /usr/local/bin/) that points "PowerShell" to wherever your PowerShell 7 is installed on Linux.
The default path to the actual pwsh program, if you use the latest build files from Microsoft, is /opt/microsoft/powershell/7/pwsh, but that's already symlinked to /usr/bin/pwsh so you could link there instead:
sudo ln -s /opt/microsoft/powershell/7/pwsh /usr/local/bin/PowerShell
Description
Hi We need to deploy a TCP server with a "different known" port so we selected an azure cloud service. My team has different OS so we need to deploy with powershell code. We also enabled the "Enable-AzureRmAlias" command to avoid errors. In both operating systems we got the same error.
The term 'New-AzureServiceProject' is not recognized as the name of a cmdlet
Steps to reproduce
We tried the same steps in MACOS and a windows 7 machine and followed the azure tutorial:
https://learn.microsoft.com/en-us/azure/cloud-services/cloud-services-nodejs-develop-deploy-express-app
Everything works fine until the New-AzureServiceProject expressapp command.
Environment data
In both machines we got:
$PSVersionTable.PSVersion
Major Minor Patch PreReleaseLabel BuildLabel
6 2 1
Get-InstalledModule -Name Az -AllVersions | select Name,Version
Name Version
Az 2.4.0 Az 2.3.2
az --version
azure-cli 2.0.67 *
Error output
New-AzureServiceProject : The term 'New-AzureServiceProject' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ New-AzureServiceProject helloworld
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-AzureServiceProject:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
New-AzureServiceProject is using the Azure module, this command is working well on my windows 10. I have PSVersion 5.1.17763.503.
To avoid this, you must make sure that you've got the Azure module 5.3.0+ install and NO other older version. Once that's installed, force installs the Az module again. You could follow this to migrate existing scripts to Az and more details from this SO question about Az / AzureRM / Legacy Azure Powershell Conflicts
I want to convert an .exe file using the DesktopAppConverter tool, using this command
DesktopAppConverter.exe -Installer 'D:\Projects\Finance Workspace\New folder\deploy\exe only\pac
kages\bundles\Fun Money-1.0.exe' -Destination 'D:\Projects\Finance Workspace\New folder\deploy\exe only\packages\bundles
\appX' -PackageName "Funmoney" -Publisher "CN=Derbyware" -Version 1.0.0.0 -MakeAppx
I get this error
DesktopAppConverter : error 'E_NO_EXPANDED_BASE_IMAGE': No expanded
base images were found at 'C:\ProgramData\Microsoft\Windows\Images'.
Please run with -Setup to expand a new base image. At line:1 char:1
How Can I fix this please ??
To convert an app you need to download a Docker base image of Win10, with the same build number as your machine has.
Details on what to download and how to configure
Also, If you have problems with the Microsoft DAC you try this new converter, it is much easier to use, it has a GUI (no command line), built-in support for digital signing and allows you to customize the list of files that get inside your AppX.
Also, you can generate AppX packages for applications which do not (cannot) install silently.
It runs on Windows 7 too, not just Windows 10 (recommended).
I am writing a powershell script to install add-ins to Excel. The issue is I can not find a way to install a COM add-in to excel via powershell. Do you have any sugegstions. I tried to add it under the registry but just got Module Errors.
Thanks.
For this I believe you need to have Excel installed on the computer. Then you can run the following command:
$Excel = New-Object -ComObject Excel.Application
You might want to just look at the open source dfinkle/ImportExcel module.