Sign in to follow this  
Followers 0
aggg63

Script works in user session, doesn't work without session

5 posts in this topic

#1 ·  Posted (edited)

Hello.

I write this script. It works fine when I execute the script in a user session. This user is administrator in the server (W2K3). The script must run every 15 minutes. When I close the session the script fails to execute the command

RunWait($fitxerEVA & ' /S')
I know I can't use commands related to desktop (send, winactivate, etc). In the script I mapped a network share folder , write a file to log results and execute a command in the share folder. I try many variations to run the command as you can see below, nothing works when the session in closed. The script is a task in Windows. Can anybody help me? Thanks.

; CONNEXIO
if DriveMapGet("T:")='' then
    DriveMapAdd('T:','\\files.domain.es\ev.ubs',0,'user','password')
    if not @error then
        $unitatEV='T:'
        _FileWriteLog($fitxerRegistre,'Unitat EV mapeada')
    else
        _FileWriteLog($fitxerRegistre,'Unitat EV error')
    endif
else
    $unitatEV='T:'
    _FileWriteLog($fitxerRegistre,'Unitat EV asignada')
endif
sleep(5*1000) ; 5 segons

; RECOLLIDA DE DADES (Zones)
For $i=1 To $zonesPR[0]
    $dirZona=$unitatEV & '\' & $zonesPR[$i]
    $fitxerEVA=$dirZona & '\evagent.exe'
    if FileExists($fitxerEVA) then
        ;MsgBox(0,"Dir results",$dirZona & '\results')
        $llistaFitxers=_FileListToArray($dirZona & '\results','*',1)
        if isArray($llistaFitxers) then
            $hihaFitxers=TRUE
            $nf=$llistaFitxers[0]
            _FileWriteLog($fitxerRegistre,'Punt recollida: ' & StringUpper($zonesPR[$i]))
            _FileWriteLog($fitxerRegistre,'Fitxers presents: ' & $nf)
            ;_FileWriteLog($fitxerRegistre,$fitxerEVA & ' /S')
            ;$proceso=Run($fitxerEVA & ' /s',@ScriptDir,@SW_HIDE)
            RunWait($fitxerEVA & ' /S')
            ;ShellExecuteWait($fitxerEVA,"/S",@ScriptDir)
            ;RunAsWait("user",@ComputerName,"password",2,$fitxerEVA & ' /S',@ScriptDir)
            ;_FileWriteLog($fitxerRegistre,'proceso: ' & $proceso)
            sleep(5*1000) ; 5 segons
            $nf=0
            $llistaFitxers=_FileListToArray($dirZona & '\results','*',1)
            if isArray($llistaFitxers) then $nf=$llistaFitxers[0]
            _FileWriteLog($fitxerRegistre,'Fitxers pendents: ' & $nf)
        endif
    else
        _FileWriteLog($fitxerError,'No existeix el fitxer ' & $fitxerEVA)
    endif
next
if $hihaFitxers then _FileWriteLog($fitxerRegistre,'----------')

sleep(5*1000) ; 5 segons
DriveMapDel($unitatEV)
Edited by aggg63

Share this post


Link to post
Share on other sites



I don't think you can map drives without having a session active.

Try using UNC path?

Also this is probably not an autoit specific challenge, so a quick google search may give you some hints:

http://www.google.com/search?q=when+not+logged+on+does+not+work+windows

Share this post


Link to post
Share on other sites

Thanks.

I try UNC path and doesn't work. I think is a problem in credentials for network share folder.

I don't think you can map drives without having a session active.

Try using UNC path?

Also this is probably not an autoit specific challenge, so a quick google search may give you some hints:

http://www.google.com/search?q=when+not+logged+on+does+not+work+windows

Share this post


Link to post
Share on other sites

Create a windows service, as the script always run ever 15 min.

Check adlib

Maybe its a good catch if you run the service with a specific user.

Cheers.


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites

Hello.

The problem is solved.

The program must be executed with the command START

$fitxerEVA='\\files.domain.es\ev.ubs\zone\evagent.exe'
RunWait(@ComSpec & ' /c start ' & $fitxerEVA & ' /S',@ScriptDir,@SW_HIDE)

Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0