cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ctw
Engaged Sweeper III
To get better reporting on our users laptops we would like to run LSPush to our LS server when the laptops achieve any network connection. I would like this to be an easy installation that could just be the exe and batch file for users to download and run the batch file. I was looking into trying to script a task schedule for running the exe as admin so it reported drive encryption status just when it had and active network connection. I would normally look into how to do this myself, but I have an audit coming up and need to start collecting info soon.
1 ACCEPTED SOLUTION
ctw
Engaged Sweeper III
So I have it working for what we need. Ended up having to make two batch files, an xml file for the task scheduler, then include the lspush.exe.

First bat is the install for the xml that is run as admin:

@echo off

schtasks /create /xml c:\ls\lspush.xml /tn lspush

pause


This is the 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>2017-03-23T12:29:54.6885051</Date>
<Author>comp-name\user</Author>
<URI>\lspush</URI>
</RegistrationInfo>
<Triggers>
<EventTrigger>
<Enabled>true</Enabled>
<Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Microsoft-Windows-NetworkProfile/Operational"&gt;&lt;Select Path="Microsoft-Windows-NetworkProfile/Operational"&gt;*[System[Provider[@Name='Microsoft-Windows-NetworkProfile'] and EventID=10000]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
</EventTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-18</UserId>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>true</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>PT1H</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\ls\lspush.bat</Command>
</Exec>
</Actions>
</Task>


Last is the bat that runs the lspush when the laptop gets any network connectivity:

@echo off

c:\ls\lspush.exe publicip 9524

pause



This allows us to get updates on any computers as long as they don't mess with the C:\ls directory with the the batches and lspush.exe.

View solution in original post

6 REPLIES 6
Bruce_B
Lansweeper Alumni
Thank you for the update!
ctw
Engaged Sweeper III
So I have it working for what we need. Ended up having to make two batch files, an xml file for the task scheduler, then include the lspush.exe.

First bat is the install for the xml that is run as admin:

@echo off

schtasks /create /xml c:\ls\lspush.xml /tn lspush

pause


This is the 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>2017-03-23T12:29:54.6885051</Date>
<Author>comp-name\user</Author>
<URI>\lspush</URI>
</RegistrationInfo>
<Triggers>
<EventTrigger>
<Enabled>true</Enabled>
<Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Microsoft-Windows-NetworkProfile/Operational"&gt;&lt;Select Path="Microsoft-Windows-NetworkProfile/Operational"&gt;*[System[Provider[@Name='Microsoft-Windows-NetworkProfile'] and EventID=10000]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
</EventTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-18</UserId>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>true</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>PT1H</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\ls\lspush.bat</Command>
</Exec>
</Actions>
</Task>


Last is the bat that runs the lspush when the laptop gets any network connectivity:

@echo off

c:\ls\lspush.exe publicip 9524

pause



This allows us to get updates on any computers as long as they don't mess with the C:\ls directory with the the batches and lspush.exe.
ctw
Engaged Sweeper III
The laptops are not domain joined, so that wouldn't work for us.
njett
Engaged Sweeper III
Another option depending on your infrastructure is to push the scheduled task out via GPO.

We also run the LSPUSH.exe from a file share when the laptops are internal to our network.
ctw
Engaged Sweeper III
I saw that one, but it wasn't within the specifications of what I was doing. I've done something similar and will post the results once I'm positive that it works. Basically I made a scheduled task to run a batch file on network connection, exported that working task, made a batch file to install the xml to another system, then used iexpress to stupid proof the installation for users. I just need to test that it's working then I'll do a write up.
Bruce_B
Lansweeper Alumni
This forum topic may be helpful. We unfortunately don't have a set procedure for setting up a scheduled task via a script.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now