Luis Diaz
asked on
Batch/VBScript : Disable Windows tasks
Hello experts,
I have a window task which is located in more than 20 servers. The name of this task is the same. I am declared as administrator in the various servers.
I was wondering if there is a command in order to disable this task automatically by reporting the name of the windows task and the various servers in which I need to disable it.
If you have questions, please contact me.
I have a window task which is located in more than 20 servers. The name of this task is the same. I am declared as administrator in the various servers.
I was wondering if there is a command in order to disable this task automatically by reporting the name of the windows task and the various servers in which I need to disable it.
If you have questions, please contact me.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@oBdA:
I tested your proposal and it works perfectly! Thank you again for your help!
I tested your proposal and it works perfectly! Thank you again for your help!
ASKER
@oBdA:
Just one remark, how should we revise the script in order to be able to report multiple tasks in the variable
Set taskname?
Example Set Taskname:Task1;Task2;Task3 ?
Thank you very much for your help.
Just one remark, how should we revise the script in order to be able to report multiple tasks in the variable
Set taskname?
Example Set Taskname:Task1;Task2;Task3
Thank you very much for your help.
Tasks containing spaces must be enclosed in double quotes in the list.
@echo off
setlocal
set TaskName="Some Task 1" "Some Task 2"
set ServerList=C:\Temp\servers.txt
for /f %%a in ('type "%ServerList%"') do (
echo Processing %%a ...
for %%t in (%TaskName%) do (
echo - disabling '%%~t' ...
ECHO schtasks.exe /change /s %%a /tn "%%~t" /disable
)
)
ASKER
Thank you very much for this proposal!
ASKER
I am going to check psexec. Thank you very much for this proposal.