cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
itssn
Engaged Sweeper II
Made this using owexec.exe, which makes possible to execute scripts on remote computer using user account username and password.

You can download owexec.exe at http://officewarfare.net/index.php/owexec/

Make two bach files; run.bat and getNetUse.bat and place them into lansweeper actions share, see below:

-------------run.bat---------------
@echo off

\\%LANSWEEPER ACTIONS SHARE%\owexec -nowait -k "%LANSWEEPER ACTIONS SHARE%\getNetUse.bat" -copy -c %1

:CHEK
if exist "\\%LANSWEEPER ACTIONS SHARE%\temp\NetUse.txt" (
type \\%LANSWEEPER ACTIONS SHARE%\temp\NetUse.txt
del \\%LANSWEEPER ACTIONS SHARE%\temp\NetUse.txt
pause

) else (
@ping -n 5 -w 1000 0.0.0.1 > NUL
GOTO CHEK
)


------------getNetUse.bat-------------
@echo off
REM get net use
net use > \\%LANSWEEPER ACTIONS SHARE%\temp\NetUse.txt



The 'temp' folder must have full acces to all user accounts (Domain users), because owexec will copy there NetUse.txt from user computer.

In Lansweeper console make new custom action with action

{actionpath}run.bat {computer}


Tested on XP and Vista with Lansweeper 4.0

One thing I dont like, is CMD window showing on user side for a second, maybe someone can suggest how to avoid it.

Thanks, Jo from http://officewarfare.net/index.php/owexec/ for an idea 🙂
3 REPLIES 3
Daniel_B
Lansweeper Alumni
Could you attach a screenshot of the error message you are facing?
LewisJPeters
Engaged Sweeper II
I get an error saying I need to specify file location? Do I need to change something in the script?
techdesign
Engaged Sweeper
I was able to get this to work without the popup by using an intermediate vbscript file that launches the batch file hidden. I'm sure this could be made even better if someone rewrote it to just use vbscript to dump the network drive letter and path, but coming up with this made me break out in a sweat as it is.

Here is the "batchlauncher.vbs" file (I found it in an old newsgroup post from a 'Torgeir Bakken'...thanks!)
sTitle = "Batch launcher"

Set oArgs = WScript.Arguments
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")

If oArgs.Count <> 1 Then
' Will die after 10 seconds if no one is pressing the OK button
oShell.Popup "Error: You need to supply a file path " _
& "as input parameter!", 10, sTitle, vbCritical + vbSystemModal

Wscript.Quit 1
End If

sFilePath = oArgs(0)

If Not oFSO.FileExists(sFilePath) Then
' Will die after 10 seconds if no one is pressing the OK button
oShell.Popup "Error: Batch file not found", _
10, sTitle, vbCritical + vbSystemModal

Wscript.Quit 1
End If

' add quotes around the path in case of spaces
iRC = oShell.Run("""" & sFilePath & """", 0, True)

' Return with the same errorlevel as the batch file had
Wscript.Quit iRC


I then modified the run.bat command as follows:
@echo off

\\%LANSWEEPER ACTIONS SHARE%\owexec -nowait -k "wscript.exe" -p "\\%LANSWEEPER ACTIONS SHARE%\batchlauncher.vbs \\%LANSWEEPER ACTIONS SHARE%\getNetUse.bat" -c %1

:CHEK
if exist "\\%LANSWEEPER ACTIONS SHARE%\temp\NetUse.txt" (
type \\%LANSWEEPER ACTIONS SHARE%\temp\NetUse.txt
del \\%LANSWEEPER ACTIONS SHARE%\temp\NetUse.txt
pause

) else (
@ping -n 5 -w 1000 0.0.0.1 > NUL
GOTO CHEK
)


In the tests I've done, this achieves the exact same function, but without the command prompt window popping up momentarily.