K
kingoffarex
Guest
hey ,
im begginer in coding and want code a scheduler to prayers
i can create the task in vb.net using this code
how can i do that in c#
Dim path = Environ("temp") & "\x"
Dim change As String = My.Resources._957970
change = Replace(change, "%i%", My.User.CurrentPrincipal.Identity.Name.ToString())
change = Replace(change, "%path%", Application.ExecutablePath)
IO.File.WriteAllText(path, change)
Shell("schtasks.exe /create /TN " & ChrW(34) & "Updataas\AAMyname task" & ChrW(34) & " /XML " & ChrW(34) & path & ChrW(34))
using xml file :
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2001-10-25T14:27:44.8929027</Date>
<Author>%i%</Author>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
<UserId>%i%</UserId>
</LogonTrigger>
<RegistrationTrigger>
<Enabled>false</Enabled>
</RegistrationTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>%i%</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>false</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>true</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>%path%</Command>
</Exec>
</Actions>
</Task>
Continue reading...
im begginer in coding and want code a scheduler to prayers
i can create the task in vb.net using this code
how can i do that in c#
Dim path = Environ("temp") & "\x"
Dim change As String = My.Resources._957970
change = Replace(change, "%i%", My.User.CurrentPrincipal.Identity.Name.ToString())
change = Replace(change, "%path%", Application.ExecutablePath)
IO.File.WriteAllText(path, change)
Shell("schtasks.exe /create /TN " & ChrW(34) & "Updataas\AAMyname task" & ChrW(34) & " /XML " & ChrW(34) & path & ChrW(34))
using xml file :
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2001-10-25T14:27:44.8929027</Date>
<Author>%i%</Author>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
<UserId>%i%</UserId>
</LogonTrigger>
<RegistrationTrigger>
<Enabled>false</Enabled>
</RegistrationTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>%i%</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>false</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>true</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>%path%</Command>
</Exec>
</Actions>
</Task>
Continue reading...