[SOLVED]Switches and parameters for creating tasks
Moderator: DosItHelp
-
- Posts: 36
- Joined: 04 Oct 2013 14:14
[SOLVED]Switches and parameters for creating tasks
Hi, I want to use the correct switches and parameters to create a task that runs a batch file silently
It will be called 1.bat and run as onlogon?
SCHTASKS /Create /tn "1" /tr %Systemdrive%\1\1.bat /sc onlogon /ru ""
Any help with a task that will run a batch silently would be appreciated
It will be called 1.bat and run as onlogon?
SCHTASKS /Create /tn "1" /tr %Systemdrive%\1\1.bat /sc onlogon /ru ""
Any help with a task that will run a batch silently would be appreciated
Last edited by serverdelux on 31 Oct 2013 21:23, edited 2 times in total.
Re: How to pick which switches and parameters for creating t
If it triggers UAC then you can't get around that, otherwise someone could do what you are doing and get malware to install easily.
-
- Posts: 36
- Joined: 04 Oct 2013 14:14
Re: How to pick which switches and parameters for creating t
foxidrive wrote:If it triggers UAC then you can't get around that, otherwise someone could do what you are doing and get malware to install easily.
Hi, thanks for the reply. It's not triggering UAC, just need a task that runs a bat silent as I don't want to see batch console flash at onlogon. No interaction is needed from user is needed as I'm just backing up my current theme and/or wallpaper
Would appreciate any help on the task please because I don't quite understand the appropriate switches, etc to run the bat silent
And if there are multiple ways to write the task I am curious about that?
Thanks for any further help
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: How to pick which switches and parameters for creating t
Closest thing I can find would be to try calling the batch file with which MIGHT work, but I haven't tested it.
Code: Select all
start /min
-
- Posts: 36
- Joined: 04 Oct 2013 14:14
Re: How to pick which switches and parameters for creating t
ShadowThief wrote:Closest thing I can find would be to try calling the batch file withwhich MIGHT work, but I haven't tested it.Code: Select all
start /min
Thanks for your help!
I have that in mind as last resort but found these three tasks and they all run the cmd or batch files silent so I was thinking the same thing could be done with "onlogon"
Code: Select all
schtasks /create /tn "Rearm" /tr "'%%SystemDrive%%\Windows\system32\cmd.exe' /c cscript.exe /b C:\Windows\System32\slmgr.vbs /rearm && net stop sppsvc && net start sppsvc" /sc daily /mo 30 /ru "" /f
Code: Select all
schtasks /create /tn "Tour" /tr "%SystemDrive%\LAS\7.bat" /sc onstart /ru ""
Code: Select all
schtasks /create /tn "Defrance" /tr "%SystemDrive%\Semi\5.bat" /sc daily /mo 1 /ru ""
One uses the /f switch but all use the "" but silently run batch ...lol
-
- Posts: 36
- Joined: 04 Oct 2013 14:14
Re: How to pick which switches and parameters for creating t
Hi, taking a break from creating silent task for now here is it is...
Right now I need help creating a task that runs as soon as it is created
Is it the "once" parameter?
I went into the task scheduler and created a task that runs when it's created/modified
But need help putting it into batch form
Any help would be appreciated
Thanks
Code: Select all
schtasks /create /tn "task1" /tr "%SystemDrive%\1.bat" /sc onlogon /ru "" >nul
Right now I need help creating a task that runs as soon as it is created
Is it the "once" parameter?
I went into the task scheduler and created a task that runs when it's created/modified
But need help putting it into batch form
Any help would be appreciated
Thanks
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: How to pick which switches and parameters for creating t
Doesn't look like you can run the task with the same command you use to create the task, but you can manually run a task with
Code: Select all
SCHTASKS /Run [Connect_Options] /TN taskname
-
- Posts: 36
- Joined: 04 Oct 2013 14:14
Re: How to pick which switches and parameters for creating t
ShadowThief wrote:Doesn't look like you can run the task with the same command you use to create the task, but you can manually run a task withCode: Select all
SCHTASKS /Run [Connect_Options] /TN taskname
I want to create a task that runs as soon as it created
This is possible and tested if using task scheduler to create it but I need the batch to do it so I don't have to open up task scheduler
Here is an exported XML that does it if anyone want's to look at in task scheduler
Code: Select all
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2013-10-21T14:41:03.8192848</Date>
<Author>Jesus-PC\Jesus</Author>
</RegistrationInfo>
<Triggers>
<RegistrationTrigger>
<Enabled>true</Enabled>
</RegistrationTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>Jesus-PC\Jesus</UserId>
<LogonType>Password</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>%systemdrive%\remove1.bat</Command>
</Exec>
</Actions>
</Task>
Save as .xml and import to task scheduler to test
When created it will automatically run whatever actions you designate
So ultimately I wan't the task to be part of a batch file and not open task scheduler
Thanks
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: How to pick which switches and parameters for creating t
serverdelux wrote:I want to create a task that runs as soon as it created
Code: Select all
schtasks /create /tn "task1" /tr "%SystemDrive%\1.bat" /sc onlogon /ru "" >nul
schtasks /run /tn "task1"
-
- Posts: 36
- Joined: 04 Oct 2013 14:14
Re: How to pick which switches and parameters for creating t
ShadowThief wrote:serverdelux wrote:I want to create a task that runs as soon as it createdCode: Select all
schtasks /create /tn "task1" /tr "%SystemDrive%\1.bat" /sc onlogon /ru "" >nul
schtasks /run /tn "task1"
I just have to code it into my function here
viewtopic.php?f=3&t=4993
Ideally one schtasks cmd is what I want and would have resorted to schtasks /run eventually but I appreciate your help and creativity a lot so I can attempt to finish my function
-
- Posts: 36
- Joined: 04 Oct 2013 14:14
Re: How to pick which switches and parameters for creating t
Hi again, I'm working on my original task again to have it run silent but call another batch at onlogon
Task1
It runs silent at onlogon but it doesn't run 2.bat batch when called ...lol
Also if I open up task scheduler and run it also runs silent but doesn't call 2.bat to run
If I manually run 1.bat it will call 2.bat and it runs
What is going on here?
Is it cause the 1.bat is silent that it won't call 2.bat?
It's weird
Edit:
And 2.bat needs interaction so it needs to run non-silent
It's gotta be something about the task switches or silently run tasks can't call batch files but that doesn't make sense
Any help would be appreciated...
Thanks
Task1
Code: Select all
schtasks /create /tn "Task1" /tr "%SystemDrive%\1.bat" /sc onlogon /ru ""
It runs silent at onlogon but it doesn't run 2.bat batch when called ...lol
Also if I open up task scheduler and run it also runs silent but doesn't call 2.bat to run
If I manually run 1.bat it will call 2.bat and it runs
What is going on here?
Is it cause the 1.bat is silent that it won't call 2.bat?
It's weird
Edit:
And 2.bat needs interaction so it needs to run non-silent
It's gotta be something about the task switches or silently run tasks can't call batch files but that doesn't make sense
Any help would be appreciated...
Thanks
-
- Posts: 36
- Joined: 04 Oct 2013 14:14
Re: How to pick which switches and parameters for creating t
Until I can perfect how to get the silent task to run 1.bat then call 2.bat does anyone know how to get this task
to start 1.bat with this cmd
Thanks
Edit:
Maybe something like this? I dunno
Code: Select all
schtasks /create /tn "Task1" /tr "%SystemDrive%\1.bat" /sc onlogon /ru ""
to start 1.bat with this cmd
Code: Select all
start /min
Thanks
Edit:
Maybe something like this? I dunno
Code: Select all
schtasks /create /tn "T1" /tr "cmd.exe /c start /b /min C:\1\2\1.bat" /sc onlogon /ru ""
Code: Select all
schtasks /create /tn "T1" /tr "cmd.exe /c start /b /min C:\1\2\1.bat" /sc onlogon /rl highest /f
Re: How to pick which switches and parameters for creating t
What is going on here?
-
- Posts: 36
- Joined: 04 Oct 2013 14:14
Re: How to pick which switches and parameters for creating t
zoeyku wrote:What is going on here?
lol...I wanted a task to run a batch file silent and call a non-silent batch but this is impossible as the call never happens to the second batch
Here is an interesting link that uses a .vbs file but tried that code too with no success
http://superuser.com/questions/62525/ru ... batch-file
An silent batch cannot call a second batch!
So I'm going to take my 1st batch and write it in .vbs then task will just run it without flashing console and call second batch
[NOT SOLVABLE...LOL]
Re: [NOT SOLVABLE] Switches and parameters for creating task
Try running hide.vbs with the batch file as parameter
Hide.vbs:
Hide.vbs:
Code: Select all
Const HIDDEN_WINDOW = 12
if WScript.Arguments.Count = 0 then
WScript.Echo "Missing parameters"
end if
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = HIDDEN_WINDOW
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create("Wscript.Arguments(0)", null, objConfig, intProcessID