Sign in to follow this  
Followers 0
TuMiM

script on network problem

11 posts in this topic

I have a script that when cloed calls another exe which writes to a log file as a user with the corredct rights. This works great when them exe is on the local machine but when run from the network, it gives an error saying:

Runwait(@TempDir & "\" & @ScriptName, 0)

Error : Unable to execute the external program.

The directory name is invalid

Any reason why this is and can it be fixed?

#include <GuiConstants.au3>

opt("trayIconHide", 1)

FileInstall("TMS Logo.jpg", @TempDir & "\", 1)
FileInstall("Writelog.exe", @TempDir & "\", 1)
FileMove(@TempDir & "\Writelog.exe", @TempDir & "\" & @scriptname)

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

;GuiCreate("Non-Authorized Application", 472, 131)
GuiCreate("Non-Authorized Application", 472, 160)

$Pic_1 = GuiCtrlCreatePic(@TempDir & "\TMS Logo.jpg", 0, 0, 125, 37)
$name = StringTrimRight ( @scriptname, 4 )
$Label_2 = GuiCtrlCreateLabel("The " & $name & " application is not allowed on owned equipment. This message acts as a warning to you for running this application. The following information will be logged for any future violations of the policy." & @CRLF & @CRLF & @computername & "=" & @UserName & " " & @mon & "\" & @MDAY & "\" & @YEAR, 140, 10, 315, 100)
GuiCtrlSetFont(-1, 9.5, 525, 2)
$Button_3 = GuiCtrlCreateButton("I Understand", 190, 119, 80, 30)

$lb = GuiCtrlCreateLabel('Computer Usage Policy', 3, 129, 90, 30)
GuiCtrlSetColor(-1, 0x0000ff)
GuiCtrlSetFont(-1, 8.5, 400, 2)
GuiCtrlSetTip(-1, 'http://intranet.company.com/intranet/home.nsf/pages/JBRO-5QLQHV')


GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        RunAsSet ( "username", "domain", "password")
        Runwait(@TempDir & "\" & @ScriptName, 0)
        RunAsSet();<-- To restore initial account
        FileDelete(@TempDir & "\" & @ScriptName)
        ExitLoop
    Case $msg = $Button_3
        RunAsSet ( "username", "domain", "password", 0)
        Runwait(@TempDir & "\" & @ScriptName)
        RunAsSet();<-- To restore initial account
        FileDelete(@TempDir & "\" & @ScriptName)
    ExitLoop
    Case $Msg = $lb
     Run(@ComSpec & ' /c start "" "http://intranet.company.com/intranet/home.nsf/pages/JBRO-5QLQHV"')
    Case Else
    ;;;
    EndSelect

WEnd

opt("trayIconHide", 1)
IniWrite("\\Fileserver\Log$\BannedApp.log" , @Scriptname, @computername, @UserName & " " & @mon & "\" & @MDAY & "\" & @YEAR)

Share this post


Link to post
Share on other sites



I have a script that when cloed calls another exe which writes to a log file as a user with the corredct rights. This works great when them exe is on the local machine but when run from the network, it gives an error saying:

Runwait(@TempDir & "\" & @ScriptName, 0)

Error : Unable to execute the external program.

The directory name is invalid

Any reason why this is and can it be fixed?

#include <GuiConstants.au3>

opt("trayIconHide", 1)

FileInstall("TMS Logo.jpg", @TempDir & "\", 1)
FileInstall("Writelog.exe", @TempDir & "\", 1)
FileMove(@TempDir & "\Writelog.exe", @TempDir & "\" & @scriptname)

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

;GuiCreate("Non-Authorized Application", 472, 131)
GuiCreate("Non-Authorized Application", 472, 160)

$Pic_1 = GuiCtrlCreatePic(@TempDir & "\TMS Logo.jpg", 0, 0, 125, 37)
$name = StringTrimRight ( @scriptname, 4 )
$Label_2 = GuiCtrlCreateLabel("The " & $name & " application is not allowed on owned equipment. This message acts as a warning to you for running this application. The following information will be logged for any future violations of the policy." & @CRLF & @CRLF & @computername & "=" & @UserName & " " & @mon & "\" & @MDAY & "\" & @YEAR, 140, 10, 315, 100)
GuiCtrlSetFont(-1, 9.5, 525, 2)
$Button_3 = GuiCtrlCreateButton("I Understand", 190, 119, 80, 30)

$lb = GuiCtrlCreateLabel('Computer Usage Policy', 3, 129, 90, 30)
GuiCtrlSetColor(-1, 0x0000ff)
GuiCtrlSetFont(-1, 8.5, 400, 2)
GuiCtrlSetTip(-1, 'http://intranet.company.com/intranet/home.nsf/pages/JBRO-5QLQHV')
GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        RunAsSet ( "username", "domain", "password")
        Runwait(@TempDir & "\" & @ScriptName, 0)
        RunAsSet();<-- To restore initial account
        FileDelete(@TempDir & "\" & @ScriptName)
        ExitLoop
    Case $msg = $Button_3
        RunAsSet ( "username", "domain", "password", 0)
        Runwait(@TempDir & "\" & @ScriptName)
        RunAsSet();<-- To restore initial account
        FileDelete(@TempDir & "\" & @ScriptName)
    ExitLoop
    Case $Msg = $lb
     Run(@ComSpec & ' /c start "" "http://intranet.company.com/intranet/home.nsf/pages/JBRO-5QLQHV"')
    Case Else
;;;
    EndSelect

WEnd

opt("trayIconHide", 1)
IniWrite("\\Fileserver\Log$\BannedApp.log" , @Scriptname, @computername, @UserName & " " & @mon & "\" & @MDAY & "\" & @YEAR)
try

Runwait(@ScriptDir & "\" & @ScriptName, 0)

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

that won't work. The script installs the writelog.exe file to the temp directory of the local machine and then does a filemove to rename it to the same name as the running executable. That file it the temp directory needs to be called to write to the log. If i do a @scriptdir it will loop.

Share this post


Link to post
Share on other sites

that won't work. The script installs the writelog.exe file to the temp directory of the local machine and then does a filemove to rename it to the same name as the running executable. That file it the temp directory needs to be called to write to the log. If i do a @scriptdir it will loop.

i guess it would have helped to actually read the script first... sorry about that... few things... you're using runasset without loading the profile, maybe try using 1 to load the profile, if that doesn't work, you could use an explicit path rather than @TempDir, try replacing @TempDir w/ "C:\Temp"

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

If i load the profile then it will not be the same Temp directory. When a user runs the script it uses their temp directory and not the Runasset users temp directory. That is why I have it set to not load the profile for runasset. I also cannot use a set path because not everyone has the same path but everyone has a temp directory set.

Share this post


Link to post
Share on other sites

If i load the profile then it will not be the same Temp directory. When a user runs the script it uses their temp directory and not the Runasset users temp directory. That is why I have it set to not load the profile for runasset. I also cannot use a set path because not everyone has the same path but everyone has a temp directory set.

you can create the path in the script so that they WOULD have it to use explicitly...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Is it possible to run this script from a network share?

\\server\script\script.exe


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

When running under a different credential it is likely the @Temp will be different. So use a fixed path like "C:\Temp" and also make sure you specify the WorkingDir on theRunwait command;

Runwait("c:\temp\" & @ScriptName,"c:\temp" )

Because it is also likely that the @workingdir still points to the Networkshare which probably isn't accessibly with the RunAs credentials....


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Is it possible to run this script from a network share?

\\server\script\script.exe

no, that's the problem I am having. It works from local but not from a network share

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Maybe above lines can help you.

-When a prog Runs onother prog and goes on the last prog "carry" a set of user credentials info with it.

-This info is taken by the initial user started the prog,except a runas like command was inside the code of one runned file.

-Finally analyze your network shares.They can have different credentials of that client user credentials are.Also analyze with witch credentials your prog starts first time!

Example:

If a prog started from a network share or from anywhere and carries different credentials from that Client's user you could have permition problems.To avoid any problem you must start your prog and look like it had been runned from local.

To do that you must know the credentials of Client's user.Including password

RunAsSet(@UserName,@LogonDomain,$Userpassword,0)

($userpassword must be declared)

Edited by Amen

Share this post


Link to post
Share on other sites

The syntax of your code isn't correct (see comment). I had this same problem a few days ago, I specified a working dir and all was well.

Case $msg = $GUI_EVENT_CLOSE       
        RunAsSet ( "username", "domain", "password")
        ; Why is there a 0 here? 
        Runwait(@TempDir & "\" & @ScriptName, 0); Should be something like Runwait(@TempDir & "\" & @ScriptName, @Temp)
        RunAsSet();<-- To restore initial account
        FileDelete(@TempDir & "\" & @ScriptName)
        ExitLoop
    Case $msg = $Button_3
        RunAsSet ( "username", "domain", "password", 0)
       ; You need to provide a working dir here also.
        Runwait(@TempDir & "\" & @ScriptName); Try Runwait(@TempDir & "\" & @ScriptName, @Temp)
        RunAsSet();<-- To restore initial account
        FileDelete(@TempDir & "\" & @ScriptName)

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