Now that PowerShell has been released, I've sworn off .BAT files forever. I have a few .BAT files that I'm converting to PowerShell scripts.
Here's one way to quickly convert your legacy .BAT files to PowerShell scripts that you can run from Desktop shortcuts:
Step 1: Enable script execution. By default, PowerShell doesn't allow script execution. If you execute the Get-ExecutionPolicy command immediately after installing PowerShell you'll see that the execution policy is "Restricted" which means that no scripts can be run. You can enable script execution with the Set-ExecutionPolicy command. Set the execution policy to "RemoteSigned" to allow execution of unsigned local scripts, and signed scripts downloaded from the Internet. Set the execution policy to RemoteSigned as follows:
PS C:\temp> Set-ExecutionPolicy RemoteSigned
Step 2: Create a folder in which your scripts will be stored. For example, create a folder named C:\PSScripts.
Step 3: Add a script file named Example.ps1 to the C:\PSScripts folder. Note, that's a digit one at the end of the .ps1 file type. Add the following text to Example.ps1:
Write-Output "Hello" Start-Sleep -Seconds 10 Write-Output "Goodbye" Start-Sleep -Seconds 10
Step 4: Create a Desktop shortcut to PowerShell: Click Start / Programs / Windows PowerShell 1.0 and right-click Windows PowerShell and click Copy. Then right-click the Desktop and click Paste.
Step 5: Rename the Desktop shortcut to Example. Right-click the shortcut, click Properties, and select the Shortcut tab. In the Target text box enter the following:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -command "& 'C:\PSScripts\Example.ps1' "
Now when you double-click the Desktop shortcut the Example.ps1 script will run.
Name | Comment | URL | Date/Time |
Mansoor | Hi, Thanks a lot for shareing ur code for creating bat files with powershell .This was very full for my project,.... thanks once again.... -Mansoor | November 5, 2009 | |
Kenny Joseph | Thanks! | May 18, 2009 |
Title | Date |
EBTCalc (Android) Version 1.53 is now available | May 19, 2024 |
Vault 3 Security Enhancements | October 24, 2023 |
Vault 3 is now available for Apple OSX M2 Mac Computers! | September 18, 2023 |
Vault (for Desktop) Version 0.77 Released | March 26, 2023 |
EBTCalc (Android) Version 1.44 is now available | October 12, 2021 |
Vault (Desktop) Version 0.72 Released | October 6, 2021 |
EBT Compass is Now Available for Android Devices | June 2, 2021 |