topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday April 9, 2026, 8:52 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Recent Posts

Pages: prev1 ... 15 16 17 18 19 [20] 21 22 23 24 25 ... 225next
476
Sorry, meant to say upload a couple of the shortcut .lnk files not icons.  :-[

Problem I'm having is trying to get PowerShell to accept what is a virtual path, the FOLDERID_AppsFolder in the python script.
477
I thought it might be looking at the PNG images in the Assets folder, I can get the path and executable via PowerShell but none of the executables contain an icon according to Windows.

Trouble is working out which PNG to use since due to standards the names aren't standard.

The PowerShell commands to get all the info pertaining to Apps are:
Get-AppxPackage
Get-AppxPackageManifest

Also, the manifest for some apps, (eg. Photos & Video Editor) is the same since the only difference is the entry point into the app which you can see in the shortcuts my script above created:

Photos:        C:\Windows\explorer.exe shell:Appsfolder\Microsoft.Windows.Photos_8wekyb3d8bbwe!App
Video Editor: C:\Windows\explorer.exe shell:Appsfolder\Microsoft.Windows.Photos_8wekyb3d8bbwe!SecondaryEntry

Below is a small script that gets the App name, ID, path, executable, and logo:
Code: PowerShell [Select]
  1. cls
  2. $apps = (Get-StartApps)
  3. #$apps | Get-Member
  4. $j = 0
  5. for ($i = 0; $i -lt $apps.Count; $i++) {
  6.   if (($apps[$i].AppID).Contains("!")) {
  7.     $j++
  8.     Write-Host "Name: $($apps[$i].Name)"
  9.     Write-Host "  AppID: $($apps[$i].AppID)"
  10.     $package = Get-AppxPackage -Name ($apps[$i].AppID).SubString(0, ($apps[$i].AppID).IndexOf("_"))
  11. #    if ($package.SignatureKind -eq "Store") {
  12. #      $package | Get-Member
  13.       Write-Host "  InstallLocation: $($package.InstallLocation)"
  14.       $manifests = Get-AppxPackageManifest -Package $package
  15.       foreach ($manifest in $manifests) {
  16.         foreach($app in $manifest.Package.Applications.Application) {
  17. #          $app | Get-Member
  18. #          Write-Host "  Id: $($app.Id)"
  19.           Write-Host "  Executable: $($app.Executable)"
  20.           Write-Host "  Logo: $($manifest.Package.Properties.Logo)"
  21.         }
  22.       }
  23. #    }
  24.   }
  25. }
  26. Write-Host $j

The remarked lines are just me experimenting with trying to narrow down the list.

Output
Code: Text [Select]
  1. Name: GetThemAll - Video Downlaoder
  2.   AppID: NimbusWeb.GetThemAll-VideoDownlaoder_p5fjnfwkc9ns0!App
  3.   InstallLocation: C:\Program Files\WindowsApps\NimbusWeb.GetThemAll-VideoDownlaoder_2.3.2.0_x64__p5fjnfwkc9ns0
  4.   Executable: NativeMessagingFFMPEG.exe
  5.   Logo: Assets\StoreLogo.png
  6. Name: Microsoft Edge
  7.   AppID: Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge
  8.   InstallLocation: C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe
  9.   Executable: MicrosoftEdge.exe
  10.   Logo: Assets\MicrosoftEdgeSquare50x50.png
  11.   Executable: MicrosoftEdgeCP.exe
  12.   Logo: Assets\MicrosoftEdgeSquare50x50.png
  13.   Executable: MicrosoftEdgeCP.exe
  14.   Logo: Assets\MicrosoftEdgeSquare50x50.png
  15.   Executable: MicrosoftEdgeCP.exe
  16.   Logo: Assets\MicrosoftEdgeSquare50x50.png
  17.   Executable: MicrosoftPdfReader.exe
  18.   Logo: Assets\MicrosoftEdgeSquare50x50.png
  19. Name: Connect
  20.   AppID: Microsoft.PPIProjection_cw5n1h2txyewy!Microsoft.PPIProjection
  21.   InstallLocation: C:\Windows\SystemApps\Microsoft.PPIProjection_cw5n1h2txyewy
  22.   Executable: Receiver.exe
  23.   Logo: Assets\StoreLogo.png
  24. Name: Cortana
  25.   AppID: Microsoft.Windows.Cortana_cw5n1h2txyewy!CortanaUI
  26.   InstallLocation: C:\Windows\SystemApps\Microsoft.Windows.Cortana_cw5n1h2txyewy
  27.   Executable: SearchUI.exe
  28.   Logo: Assets\Icons\MediumTile.png
  29.   Executable: RemindersShareTargetApp.exe
  30.   Logo: Assets\Icons\MediumTile.png
  31.   Executable: Cain.exe
  32.   Logo: Assets\Icons\MediumTile.png
  33. Name: Mixed Reality Portal
  34.   AppID: Microsoft.Windows.HolographicFirstRun_cw5n1h2txyewy!App
  35.   InstallLocation: C:\Windows\SystemApps\Microsoft.Windows.HolographicFirstRun_cw5n1h2txyewy
  36.   Executable: MixedRealityPortal.exe
  37.   Logo: Assets\MixedRealityPortalMedTile.png
  38. Name: Windows Defender Security Centre
  39.   AppID: Microsoft.Windows.SecHealthUI_cw5n1h2txyewy!SecHealthUI
  40.   InstallLocation: C:\Windows\SystemApps\Microsoft.Windows.SecHealthUI_cw5n1h2txyewy
  41.   Executable: SecHealthUI.exe
  42.   Logo: Assets\DefenderAppSplashScreen.scale-400.png
  43. Name: Settings
  44.   AppID: windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel
  45.   InstallLocation: C:\Windows\ImmersiveControlPanel
  46.   Executable: SystemSettings.exe
  47.   Logo: images\logo.png
  48. Name: Print 3D
  49.   AppID: Microsoft.Print3D_8wekyb3d8bbwe!App
  50.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Print3D_3.1.2612.0_x64__8wekyb3d8bbwe
  51.   Executable: Print3D.exe
  52.   Logo: Assets\manifestAssets\StoreLogo.png
  53. Name: Get Help
  54.   AppID: Microsoft.GetHelp_8wekyb3d8bbwe!App
  55.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.GetHelp_10.1706.12921.0_x64__8wekyb3d8bbwe
  56.   Executable: GetHelp.exe
  57.   Logo: Assets\Logo.png
  58. Name: Maps
  59.   AppID: Microsoft.WindowsMaps_8wekyb3d8bbwe!App
  60.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsMaps_5.1812.10071.0_x64__8wekyb3d8bbwe
  61.   Executable: Maps.exe
  62.   Logo: Assets\AppTiles\MapsStoreLogo.png
  63. Name: Messaging
  64.   AppID: Microsoft.Messaging_8wekyb3d8bbwe!x27e26f40ye031y48a6yb130yd1f20388991ax
  65.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Messaging_4.1901.10241.0_x64__8wekyb3d8bbwe
  66.   Executable: MessagingApplication.exe
  67.   Logo: Assets\StoreLogo.png
  68. Name: Calculator
  69.   AppID: Microsoft.WindowsCalculator_8wekyb3d8bbwe!App
  70.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1812.10048.0_x64__8wekyb3d8bbwe
  71.   Executable: Calculator.exe
  72.   Logo: Assets\CalculatorStoreLogo.png
  73. Name: 3D Viewer
  74.   AppID: Microsoft.Microsoft3DViewer_8wekyb3d8bbwe!Microsoft.Microsoft3DViewer
  75.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Microsoft3DViewer_6.1903.4012.0_x64__8wekyb3d8bbwe
  76.   Executable: 3DViewer.exe
  77.   Logo: Assets\StoreLogo.png
  78. Name: OneNote
  79.   AppID: Microsoft.Office.OneNote_8wekyb3d8bbwe!microsoft.onenoteim
  80.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Office.OneNote_16001.11425.20094.0_x64__8wekyb3d8bbwe
  81.   Executable: onenoteim.exe
  82.   Logo: images\OneNoteAppList.png
  83. Name: Aussie TV FTW!
  84.   AppID: 55758OcelotSoft.AussieTVFTW_jzcqt2s08q53y!App
  85.   InstallLocation: C:\Program Files\WindowsApps\55758OcelotSoft.AussieTVFTW_1.8.0.0_x64__jzcqt2s08q53y
  86.   Executable: AussieTV.exe
  87.   Logo: Assets\StoreLogo.png
  88. Name: Alarms & Clock
  89.   AppID: Microsoft.WindowsAlarms_8wekyb3d8bbwe!App
  90.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsAlarms_10.1902.633.0_x64__8wekyb3d8bbwe
  91.   Executable: Time.exe
  92.   Logo: Assets\AlarmsStoreLogo.png
  93. Name: Paint 3D
  94.   AppID: Microsoft.MSPaint_8wekyb3d8bbwe!Microsoft.MSPaint
  95.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.MSPaint_5.1811.20017.0_x64__8wekyb3d8bbwe
  96.   Executable: PaintStudio.View.exe
  97.   Logo: Assets\Logos\StoreLogo\PaintApplist.png
  98. Name: OverDrive - Library eBooks & Audiobooks
  99.   AppID: 2FA138F6.OverDriveMediaConsole_daecb9042jmvt!App
  100.   InstallLocation: C:\Program Files\WindowsApps\2FA138F6.OverDriveMediaConsole_3.8.0.5_neutral__daecb9042jmvt
  101.   Executable: MediaConsole.Win8.exe
  102.   Logo: Assets\StoreLogo.png
  103. Name: Voice Recorder
  104.   AppID: Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe!App
  105.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsSoundRecorder_10.1902.633.0_x64__8wekyb3d8bbwe
  106.   Executable: SoundRec.exe
  107.   Logo: Assets\VoiceRecorderStoreLogo.png
  108. Name: Microsoft Store
  109.   AppID: Microsoft.WindowsStore_8wekyb3d8bbwe!App
  110.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsStore_11811.1001.27.0_x64__8wekyb3d8bbwe
  111.   Executable: WinStore.App.exe
  112.   Logo: Assets\AppTiles\StoreLogo.png
  113. Name: Photos
  114.   AppID: Microsoft.Windows.Photos_8wekyb3d8bbwe!App
  115.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Windows.Photos_2019.19021.18010.0_x64__8wekyb3d8bbwe
  116.   Executable: Microsoft.Photos.exe
  117.   Logo: Assets\PhotosStoreLogo.png
  118.   Executable: VideoProjectsLauncher.exe
  119.   Logo: Assets\PhotosStoreLogo.png
  120. Name: Video editor
  121.   AppID: Microsoft.Windows.Photos_8wekyb3d8bbwe!SecondaryEntry
  122.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.Windows.Photos_2019.19021.18010.0_x64__8wekyb3d8bbwe
  123.   Executable: Microsoft.Photos.exe
  124.   Logo: Assets\PhotosStoreLogo.png
  125.   Executable: VideoProjectsLauncher.exe
  126.   Logo: Assets\PhotosStoreLogo.png
  127. Name: Camera
  128.   AppID: Microsoft.WindowsCamera_8wekyb3d8bbwe!App
  129.   InstallLocation: C:\Program Files\WindowsApps\Microsoft.WindowsCamera_2019.124.60.0_x64__8wekyb3d8bbwe
  130.   Executable: WindowsCamera.exe
  131.   Logo: Assets\WindowsIcons\StoreLogo.png
  132. 23


I can try and find some correlation regarding the image they use from the Assets folder since some folders don't contain images with the same name as other Assets folders - there maybe be something in the manifest I can work from.

EDIT: Think I found where the image is specified in the manifest - can you upload a couple or so of the icons the Python script created?
478
This Python solution works for me without running as administrator https://stackoverflow.com/a/43635956
I had to use Python 2. The .lnk shortcut files also get icons (issue 3 above).
Perhaps the approach there can be reproduced without Python.

Just as a matter of interest, what is the shortcut Target that is generated by the above script?

Does it use explorer.exe shell:.... or does it resolve to the executable?

ie. It would be easy to add an icon to the shortcut but you'd need to resolve to the executable to fetch it.
479
Changed it a little w.r.t. what's regarded as an App.
480
Post New Requests Here / Re: "IDEA" : Key Press to Replace R-Clik Navigation
« Last post by 4wd on April 03, 2019, 04:25 AM »
Shift + F10 ?

On some laptops it's sometimes the Fn + Right Control keys, (on my Dell anyway), some keyboard also use the right Windows key, (if they have one).

Or do you want a hot-key to replace the combined action: Context menu->WinAmp->Execute
481
Highly recommend what Shades said above, invest in a decent file manager.

Doing it a little differently:

2019-04-02 17_46_04.png

Put the shortcut in C:\Users\<user>\AppData\Roaming\Microsoft\Windows\SendTo, edit its Properties to point to wherever you've put the script.

Edit the path to the script:
Code: Text [Select]
  1. C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\PoSh\MoveMovies.ps1"


  • Right-click on the folder with the movies (MP4, MKV, FLV, AVI) -> Send To -> MoveMovies
  • Select the destination folder
  • Enter the gigabyte value of files to move

Hitting Cancel at any requester will exit, as will running out of space, or entering a GB value out of range.

It only checks the available space on the destination once before moving files so if you happen to copy other things to the destination that reduce the expected space then the Move-Item will fail and an error will popup, (in theory).

There's also a popup when it's finished and if you enter a number out of range.

That's about it for error checking, (hey, it's a 100% improvement over my usual error checking routines).

NOTE: Windows doesn't allow Send To on root directories so it won't work for them.  Could always add a couple of lines to call the function to ask for a Source directory instead of having it passed via Send To ... an exercise for the user.

Code: PowerShell [Select]
  1. <#
  2.   MoveMovies.ps1
  3. #>
  4. param (
  5.   [string]$source
  6. )
  7.  
  8. Add-Type -AssemblyName System.Windows.Forms
  9.  
  10. Function Get-Folder {
  11.   $objForm = New-Object System.Windows.Forms.FolderBrowserDialog
  12.   $objForm.Description = "Select destination folder"
  13.   $objForm.SelectedPath = [System.Environment+SpecialFolder]'MyComputer'
  14.   $objForm.ShowNewFolderButton = $false
  15.   $result = $objForm.ShowDialog()
  16.   if ($result -eq "OK") {
  17.     return $objForm.SelectedPath
  18.   } else {
  19.     return $null
  20.   }
  21. }
  22.  
  23. Function Get-MoveSize {
  24.   param (
  25.     [int]$max
  26.   )
  27.   [void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
  28.  
  29.   $title = 'Move Movies'
  30.   $msg = "Total GBs of files to move [1-$($max)]: "
  31.  
  32.   $text = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)
  33.   return (($text/1) * 1Gb)
  34. }
  35.  
  36. Function Send-Notification {
  37. # https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/windows-scripting/x83z1d9f(v=vs.84)
  38.   param (
  39.     [string]$msg,
  40.     [int]$type
  41.   )
  42.   $wshell = New-Object -ComObject Wscript.Shell -ErrorAction Stop
  43.   $wshell.Popup($msg, 0, "MoveMovies", $type) | Out-Null
  44. }
  45.  
  46.  
  47. $dest = (Get-Folder)
  48. if ($dest -ne $null) {
  49.   # Get disk volume label
  50.   $dDrive = ($dest | Split-Path -Qualifier)
  51.   # Get disk free space, round down to nearest whole number
  52.   $dFree = [math]::Round((gwmi Win32_LogicalDisk -Filter "DeviceID='$($dDrive)'").FreeSpace / 1Gb)
  53. } else {
  54.   break
  55. }
  56.  
  57. $moveSize = (Get-MoveSize $dFree)
  58. if (($moveSize -lt 1) -or ($moveSize -gt ($dFree * 1Gb))) {
  59.   Send-Notification "Input outside acceptable range!" 16
  60.   break
  61. }
  62.  
  63. Write-Host $dest $moveSize $dDrive ($dFree * 1Gb)
  64.  
  65. # Get list of videos in source directory
  66. $videos = (Get-ChildItem "$($source)\*" -Include *.mp4,*.mkv,*.flv,*.avi | Sort Name)
  67. for ($i = 0; $i -lt $videos.Count; $i++) {
  68.   if ($videos[$i].Length -lt $moveSize) {
  69.     Move-Item -LiteralPath "$($videos[$i].FullName)" -Destination "$($dest)"
  70.     if ($?) {
  71.       $moveSize -= $videos[$i].Length
  72.     } else {
  73.       Send-Notification "Moving file failed!" 16
  74.       break
  75.     }
  76.   } else {
  77.     Send-Notification "Maximum number of files moved into space available/allowed" 64
  78.     break
  79.   }
  80. }
482
General Software Discussion / Re: Windows 10 Announced
« Last post by 4wd on April 02, 2019, 03:58 AM »
"Prevents others from tampering with important security features."

By others they probably mean anyone who isn't Microsoft themselves and that switch is just there as a placebo effect.
483
To get the script to work on my PC I had to do these things
- the multi line comments at the top gave errors, but changing /* and */ to <# and #> fixed that.

Ooops, my bad, I added the comment after pasting into the post ... should've tested it.
I've updated the code/archive.
 
- run the cmd window as administrator
- add the Bypass argument, like so

Wasn't necessary if run from a PowerShell console, even just right-click on the script and choose Run with Powershell but you'd bump up against the ExecutionPolicy restriction - which does get to be a real PITA sometimes.  In theory you can right-click->Properties and select something like Trust this file under the Security tab ... but I haven't seen it for awhile so I may be mis-remembering.

Shouldn't need Admin privileges since you're only writing to a directory that the user owns anyway ... just tried it here, no Admin required, just had to answer '(Y)es' to the ExecutionPolicy question that pops up.

The same task can also be created manually (and deleted if no longer needed) through the Task Scheduler (win+I and search for "schedule tasks").
Not a very end-user friendly way to set this up though.

Perhaps this post which shows setting/deleting a scheduled task in Powershell may help?

Give the task a static name and have the script just check if it's there at each run using schtasks /query <taskname>, implement if it isn't and have an optional argument to the script Apps2Shortcut.ps1 -Remove to remove it if the task is no longer required.
484
Simple Powershell script, it'll create an "Installed-Apps" folder on the Desktop and populate it with shortcuts for installed ... err ... apps.

For this purpose it regards any AUMID that contains a ! and doesn't end in .exe as a valid app - as distinct from every program installed.

Run it from a Powershell console using: .\Apps2Shortcut.ps1

For some reason I couldn't get it to run from a shortcut but that's probably my fault.

You will probably get an error if you run the extracted script from the archive due to Execution Policy, there are 3 solutions:
  • Copy/Paste the script below as a new script
  • Mark the script as trusted, (it has a zone identifier in its ADS which marks it as not from the local machine)
  • Change your Execution Policy using Set-ExecutionPolicy

Standard Disclaimer: Works for me  :)

Code: PowerShell [Select]
  1. <#
  2.   Apps2Shortcut.ps1
  3. #>
  4. Function Create-Shortcut {
  5.   param (
  6.     [string]$name,
  7.     [string]$aumid
  8.   )
  9.   # Create a Shortcut with Windows PowerShell
  10.   $WScriptShell = New-Object -ComObject WScript.Shell
  11.   $Shortcut = $WScriptShell.CreateShortcut($name)
  12.   $Shortcut.TargetPath = "$env:SystemRoot\explorer.exe"
  13.   $Shortcut.Arguments = "shell:Appsfolder\$($aumid)"
  14.   $Shortcut.Save()
  15. }
  16.  
  17. $DesktopPath = [Environment]::GetFolderPath("Desktop")
  18.  
  19. if (!(Test-Path "$($DesktopPath)\Installed-Apps")) {
  20.   New-Item "$($DesktopPath)\Installed-Apps" -ItemType Directory | Out-Null
  21. }
  22.  
  23. $apps = (Get-StartApps)
  24. for ($i = 0; $i -lt $apps.Count; $i++) {
  25.   if (($apps[$i].AppID).contains("!") -and (($apps[$i].AppID).Substring(($apps[$i].AppID).Length - 4) -ne '.exe')) {
  26.     Create-Shortcut "$($DesktopPath)\Installed-Apps\$($apps[$i].Name).lnk" $apps[$i].AppID
  27.   }
  28. }

Hopefully you'll end up with something like this:

2019-04-01 10_38_59.png

To run a Powershell command from AHK you'll probably need to use: powershell.exe -C "Get-StartApps | Out-File D:\test.txt"

Use -C to run commands directly, -F to run a script.
485
General Software Discussion / Re: Listing the unused
« Last post by 4wd on March 30, 2019, 06:57 AM »
List files sorted by Last Access time:

Code: Text [Select]
  1. dir <file spec> /s /od /ta

eg. List all MP3 files on D:\

Code: Text [Select]
  1. d:
  2. cd \
  3. dir *.mp3 /s /od /ta
486
General Software Discussion / Re: youtube downloader?
« Last post by 4wd on March 30, 2019, 06:52 AM »
SlimJet browser and hit the download button.
tnx. free?

Yep

https://www.slimjet.com/
It works! Tnx!
I need a YT banner ad blocker now. =)

SlimJet is based on Chrome sourcecode so try Video Adblocker for Youtube
487
Living Room / Re: Share your photos! Travel shots, photoblogs, etc.
« Last post by 4wd on March 24, 2019, 05:11 AM »
Sunny but bloody cold.
PANO_20190324_094617.jpg
IMG_20190324_092433221_HDR.jpg
488
Living Room / Re: Share your photos! Travel shots, photoblogs, etc.
« Last post by 4wd on March 22, 2019, 01:30 PM »
Brexit got delayed...also...Are you up near Whitby?
-Stephen66515 (March 22, 2019, 12:49 PM)

Yep ... on both counts.

At Staithes for 6 months.
IMG_20170607_130310.jpg
489
Living Room / Re: Share your photos! Travel shots, photoblogs, etc.
« Last post by 4wd on March 22, 2019, 12:39 AM »
IMG_20190321_182747949.jpg

Greetings from the UK, it's Brexit -7 days (+/- nobody knows and probably no longer cares).

Which leads to:
IMG_20190321_175757498.jpg
490
Doesn't Moto have a transfer app?

Not for at least 2 years, out of interest I went looking when I got my G5+

Google's backup of apps/settings is hit or miss, sometimes it works, sometimes it doesn't, sometimes you can't even enable it - which I can't even though It has worked on my current phone previously.

The only 100% working method I've found is unlock the bootloader, install TWRP, root it using Magisk or something else, and then install Titanium Backup + Root - something I've done with every Android device I've ever bought.
491
General Software Discussion / Re: youtube downloader?
« Last post by 4wd on March 19, 2019, 10:09 PM »
SlimJet browser and hit the download button.
tnx. free?

Yep

https://www.slimjet.com/
492
General Software Discussion / Re: youtube downloader?
« Last post by 4wd on March 18, 2019, 01:34 PM »
SlimJet browser and hit the download button.
493
Just need to test for the existence of the output file:

Code: PowerShell [Select]
  1. if (!(Test-Path $outFile)) {
  2. ...
  3. }

Added, try it now, (haven't tested it but it should work).
494
Many thanks again to 4wd for the great help. ;)

Thanks, edited my OP, now does the lot, (.html, .htm, .mht).

Updated
495
I don't know if this is possible but it would be great if the Powershell could exclude converting htm and html files that are smaller than 3ko ?

You already have the answer, same idea as deleting the small PDFs.

Code: PowerShell [Select]
  1. $aFiles = (Get-ChildItem -Include *.html,*.htm -Path ($srcFolder + "*") -Recurse | Where-Object {$_.Length -gt 3kb} )

As for Chrome, I couldn't get it to work from PowerShell either, I'll have another look when I have time.

But you do have the args wrong, should be:
Code: PowerShell [Select]
  1. $args = "`"$($infile)`" --headless --print-to-pdf=`"$($outFile)`""

Just the arguments for the command.

Could try adding a working directory also:

Code: PowerShell [Select]
  1. Start-Process -FilePath "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -Wait -NoNewWindow -ArgumentList $args -WorkingDirectory "C:\Program Files (x86)\Google\Chrome\Application"
496
Added *.htm to the Get-ChildItem filter so no need to edit and run separately, (not tested but works in other scripts - just remove it if there's a problem).

As for .mht, you could use PowerShell to pass them through the IE core to output as PDF ... so goes the theory.

Alternatively, convert to HTML first then run the script, interesting blog post: http://raywoodcocksl...-html-mht-files.html
497
Something quick in PowerShell using wkhtmltopdf, (put the executable in the same directory as the script), and Chrome.

Recursively converts .html, .htm, and .mht to PDF files.

Btw, if it looks familiar, 90% came from here.


Run it from a PoSh console or use a shortcut with the following as the Target, (assuming shortcut in the same folder as the script):
Code: Text [Select]
  1. %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -sta -NoProfile -ExecutionPolicy Bypass -File "CTP.ps1"

CTP.ps1
Code: PowerShell [Select]
  1. <#
  2.   CTP.ps1
  3.  
  4.   Convert .htm(l) and .mht to PDF
  5. #>
  6.  
  7. Function Get-Folder {
  8.   Add-Type -AssemblyName System.Windows.Forms
  9.   $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
  10.   [void]$FolderBrowser.ShowDialog()
  11.   $temp = $FolderBrowser.SelectedPath
  12.   If($temp -eq '') {Exit}
  13.   Return $temp
  14. }  
  15.  
  16. If($PSVersionTable.PSVersion.Major -lt 3) {
  17.   Write-Host '** Script requires at least Powershell V3 **'
  18. } else {
  19.   Write-Host 'Choose input folder: ' -NoNewline -BackgroundColor DarkGreen -ForegroundColor White
  20.   $srcFolder = (Get-Folder)
  21.   Write-Host $srcFolder
  22.   Write-Host 'Choose output folder: ' -NoNewline -BackgroundColor DarkGreen -ForegroundColor White
  23.   Do {$dstFolder = (Get-Folder)} While($dstFolder -eq $srcFolder)
  24.   Write-Host $dstFolder
  25.  
  26.   # PowerShell doesn't care how many stacked '\' there are in a path, multiples will always be seen as one
  27.   # ie. C:\\\\Windows = C:\Windows
  28.   # Means you can just add to the path without worrying about the trailing character
  29.   # Collect all files bigger than 3kB
  30.   $aFiles = (Get-ChildItem -Include *.html,*.htm,*.mht -Path ($srcFolder + "\*") -Recurse | Where-Object {$_.Length -gt 3kb} )
  31.   for($i = 0; $i -lt $aFiles.Count; $i++) {
  32.     $inFile = [string]$aFiles[$i]
  33. # Substitute destination folder for source folder and tack .pdf on the end
  34. # Could probably replace the extension instead ... but laziness and all that
  35.     $outFile = $dstFolder + $inFile.Replace($srcFolder, "") + '.pdf'
  36. # If output file doesn't exist then process
  37.     if (!(Test-Path $outFile)) {
  38. # Grab the parent of the output file, create the folder structure if it doesn't exist
  39.       $temp = Split-Path $outFile -Parent
  40.       if (!(Test-Path $temp)) {
  41.         New-Item $temp -ItemType Directory | Out-Null
  42.       }
  43.  
  44.       Write-Host 'File:' $inFile -BackgroundColor DarkBlue -ForegroundColor Yellow
  45. # Switch command based on the last 3 characters of the file name, anything that isn't 'mht' gets processed
  46. # as htm(l)
  47.       switch ($inFile.Substring([Math]::Max($inFile.Length - 3, 0))) {
  48.         mht {
  49.           $args = "`"$($inFile)`" --headless --print-to-pdf=`"$($outFile)`""
  50.           Start-Process -FilePath "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -Wait -NoNewWindow -ArgumentList $args
  51.           }
  52.         default {
  53.           $args = "-p 127.0.0.1 -q `"$($inFile)`" `"$($outFile)`""
  54.           Start-Process -FilePath ".\wkhtmltopdf.exe" -Wait -NoNewWindow -ArgumentList $args
  55.           }
  56.       }
  57.     }
  58.   }
  59. }
  60. Write-Host ''
  61. Write-Host 'Close window to exit ...'
  62. cmd /c pause | out-null
498
Living Room / Re: Looking for "Smart"watch Recommendations
« Last post by 4wd on March 06, 2019, 11:40 PM »
Jokes aside, now I gotta go research the bip 2 and see if I need to wait for it or not.

Not really much concrete info available atm just hearsay, speculation, rumours, and wish lists.  The pre-order page that was up is no longer accessible but the specs it had were similar to the BIP1 with the exceptions:
  • 5ATM Water Resistance
  • No Barometric sensor
  • A little narrower

But I'd wait until it appeared on Amazfit's website before taking those as gospel.
499
Living Room / Re: Looking for "Smart"watch Recommendations
« Last post by 4wd on March 06, 2019, 06:19 PM »
Just a couple of notes on the BIP:

  • For the basic stuff nothing other than the supplied app is required, (Mi Fit), so it's fine for Notifications, Step Counter, Heart Rate, Sleep Analysis, etc, etc.
  • The BIP2 is soon to be available, (was available for pre-order for a short time) - 5ATM Water Resistance, slightly narrower, loses the Barometric sensor, albeit at a higher price - but it may prompt sales on the BIP1.

I think Apple has the best Smart Watch.

I'm looking for a smartwatch that won't murder my bank, has good battery life, and that will let me view my [Android] phone's notifications without having to take it out of my pocket.

0 out of 3 ain't that bad ... I guess.
500
Living Room / Re: How to calculate the area of a graph?
« Last post by 4wd on March 06, 2019, 03:42 PM »
http://www.mathwords...ea_under_a_curve.htm

Bearing in mind it's been 40+ years since I had to stare cross-eyed at this stuff I would have thought that since the graph was seemingly created using sampled data rather than a formula that you would have had to use the age old method of slicing and dicing the area into trapezoids, calculating their area, and then adding them together?

Or given the data you could probably just stick it into Excel and have it do it.
Pages: prev1 ... 15 16 17 18 19 [20] 21 22 23 24 25 ... 225next