Mar 18 2022 01:30 AM
Hi all,
I need to create a shortcut or something that allows the logged on user to restart the print spooler as admin is this possible?
Mar 18 2022 03:46 AM
Mar 18 2022 03:51 AM
Mar 18 2022 05:07 AM
Mar 18 2022 05:24 AM
Mar 18 2022 07:04 AM
Mar 21 2022 02:52 AM
I have got most pieces done except the install and uninstall cmd:
Also when creating the intune file what do I point it too?
Mar 22 2022 05:24 AM
Mar 22 2022 07:22 AM
Mar 23 2022 06:34 AM
So I have packaged the ps1 as the set up file and put the install/uninstall command on intune as: powershell -ex bypass -file Windows10_Restartservice.ps1
This deploys to the device and a shortcut is created (Which doesnt link to anything) but the content within the folder 'restartservice' doesn't seem to be pushed to the devices within the folder that is created via the script.
Please help!
Mar 24 2022 12:28 AM
Mar 24 2022 02:39 AM
Mar 24 2022 05:24 AM
So I have managed to get the files to appear but with the bat file itself I have noticed an issue.
When I use:
net stop Spooler
net start Spooler
net stop PCPrintProvider
net start PCPrintProvider
in a bat this doesnt work even when I run as admin. However when I copy this into a cmd window this works fine. Im assuming I need some extra code within the Bat to allow this to run without issues before creating the exe as that also didnt work when I run as admin.
Any ideas on what I need to add to get the bat file to work correctly?
Thanks in advance!
Mar 25 2022 03:13 AM
So I have managed to get the .BAT to work but as there are two services within my BAT file that depend on each other I get the following question which requires a y or n to be inputted.
How do I prepopulate a Y so it bypasses this question within the Bat file?
Mar 25 2022 03:19 AM
Mar 25 2022 03:20 AM
Mar 25 2022 04:15 AM
Hi Both @Harm_Veenstra @Rudy_Ooms_MVP
So net stop servicename /yes worked and tested to make sure I also converted this into a exe which then test and worked too! BUT when I package all the files and deploy via intune the shortcut create nor the exe that worked prior to packaging stops working! Why would this be and how do I get it to work?
My powershell script I used on set up to create the intunewin file:
#install and import module
install-packageprovider -name nuget -minimumversion 2.8.5.201 -force | out-null
Install-Module -Name 'Carbon' -AllowClobber -force | out-null
Import-Module 'Carbon'
#grant permission and restart service to take affect
Grant-ServicePermission -Name Spooler -Identity Everyone -QueryStatus -EnumerateDependents -Start -Stop
Grant-ServicePermission -Name PCPrintProvider -Identity Everyone -QueryStatus -EnumerateDependents -Start -Stop
md "c:\program files (x86)\restartservice"
copy .\restartprint.exe "c:\program files (x86)\restartservice\restartprint.exe"
copy .\PaperCut.ico "c:\program files (x86)\restartservice\PaperCut.ico"
#Create Shortcut Desktops
if (-not (Test-Path "C:\Users\Public\Desktop\Restart-Service.url"))
{
$null = $WshShell = New-Object -comObject WScript.Shell
$path = "C:\Users\Public\Desktop\Restart-Service.url"
$targetpath = "c:\program files (x86)\restartservice\restartprint.exe"
$iconlocation = "c:\program files (x86)\restartservice\PaperCut.ico"
$iconfile = "IconFile=" + $iconlocation
$Shortcut = $WshShell.CreateShortcut($path)
$Shortcut.TargetPath = $targetpath
$Shortcut.Save()
Add-Content $path "HotKey=0"
Add-Content $path "$iconfile"
Add-Content $path "IconIndex=0"
}
Mar 29 2022 02:54 AM
Mar 29 2022 03:41 AM