We have a problem. I am registering schtasks as fixlet on Windows 10.
The command below fails.
waithidden cmd.exe /C schtasks /Create /SC minute /mo 2 /TN “test1” /TR “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Unrestricted -File ‘C:\test\date.log’” /ST 10:00 /F /NP
Please let me know why.
This will take effect when you type manually in cmd. But I have to apply it as a bigfix fixlet.
Please post the actionscript command you are trying to run.
/ST 10:00 /F /NP
look like parameters to schtasks.exe, not to powershell.exe, unless your powershell script is parsing those itself?
You also have unmatched doublequotes which could be a problem, or just misstyped when you posted here, which is why a copy&paste of your action script commands would be useful.
waithidden cmd.exe /C schtasks /Create /SC minute /mo 2 /TN “test1” /TR “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Unrestricted -File ‘C:\test\date.log’” /ST 10:00 /F /NP
Running with bigfix will eventually fail.
Thank you…I’ve seen issues where ‘waithidden’.can have difficulty parsing multiple levels of quotes. I’d suggest creating a batch file as a workaround. It could also be due to Bigfix using 32-bit powershell, by default. I account for both here -
action uses wow64 redirection false
delete __appendfile
appendfile cmd.exe /C schtasks /Create /SC minute /mo 2 /TN "test1" /TR "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Unrestricted -File ‘C:\test\date.log’" /ST 10:00 /F /NP
delete scheduler.bat
move __appendfile scheduler.bat
Waithidden cmd.exe /c scheduler.bat
Edit: fixed quotes
1 Like
hello
I tried it, but it ended with code 1, and it failed.
I have experimented.
Running it from the windows command will succeed.
(schtasks /Create /SC minute /mo 2 /TN “test1” /TR “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Unrestricted -File ‘C:\test\date.log’” /ST 10:00 /F /NP)
However, if you run it with bigfix, it will fail.
My guess is that this is due to the “/ np” command.
Why would it succeed if I run it in the cmd window, and fail if I run it in bigfix?
I tried running it after changing the “/ TR” path, but it still failed.
(Waithidden cmd.exe /c schtasks /create /tn “Test” /sc WEEKLY /mo 2 /D SUN /st 02:30:00 /np /tr “C:\notepad.exe”)
Thank you.
Perhaps it’s the security context of the user running the program? The BigFix Client runs in the SYSTEM security context.
hello,
System Security Context ?? sorry, I did not understand.
Could you explain it more easily?
thank you
When you run the Scheduled Tasks program from a command line, it assumes that your user account will be the “Author” of the task. When you have the BigFix client run the same command line, you need to supply a user name to be the “Author” of the task. Add the /U or the /RU switch and see if it works:
schtasks /Create /U administrator /SC minute /mo 2 /TN "test1" /TR "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Unrestricted -File 'C:\test\date.log'" /ST 10:00 /F /NP
schtasks /Create /RU SYSTEM /SC minute /mo 2 /TN "test1" /TR "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Unrestricted -File 'C:\test\date.log'" /ST 10:00 /F /NP
Thank you for your reply.
I tested it. And the result is that the first command failed,
The second command succeeded.
(schtasks /Create /RU SYSTEM /SC minute /mo 2 /TN “test1” /TR “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Unrestricted -File ‘C:\test\date.log’” /ST 10:00 /F /NP)
But there is a problem here. You must create the current user, not the system user. Is there any other way?
thank you.
I don’t understand what you want to accomplish with your scheduled task. Perhaps if you explained the desired outcome it would help.
When I run the command, the user is system like the picture above.
(schtasks /Create /RU SYSTEM /SC minute /mo 2 /TN “test2” /TR “C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Unrestricted -File ‘C:\test\date.log’” /ST 10:00 /F /NP)
However, I need to make the user the current user as shown in the picture below.
Okay - try this one:
schtasks /Create /U administrator /P password /SC minute /mo 2 /TN "test1" /TR "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -ExecutionPolicy Unrestricted -File 'C:\test\date.log'" /ST 10:00 /F
1 Like