TuMiM Posted December 22, 2005 Share Posted December 22, 2005 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? expandcollapse popup#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) Link to comment Share on other sites More sharing options...
seandisanti Posted December 22, 2005 Share Posted December 22, 2005 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? expandcollapse popup#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) Link to comment Share on other sites More sharing options...
TuMiM Posted December 22, 2005 Author Share Posted December 22, 2005 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. Link to comment Share on other sites More sharing options...
seandisanti Posted December 22, 2005 Share Posted December 22, 2005 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" Link to comment Share on other sites More sharing options...
TuMiM Posted December 22, 2005 Author Share Posted December 22, 2005 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. Link to comment Share on other sites More sharing options...
seandisanti Posted December 22, 2005 Share Posted December 22, 2005 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... Link to comment Share on other sites More sharing options...
SpookMeister Posted December 22, 2005 Share Posted December 22, 2005 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] Link to comment Share on other sites More sharing options...
Developers Jos Posted December 22, 2005 Developers Share Posted December 22, 2005 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.... SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
TuMiM Posted December 22, 2005 Author Share Posted December 22, 2005 Is it possible to run this script from a network share?\\server\script\script.exeno, that's the problem I am having. It works from local but not from a network share Link to comment Share on other sites More sharing options...
Amen Posted January 2, 2006 Share Posted January 2, 2006 (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 January 2, 2006 by Amen Plugged ThoughtsQBsick? check my Old staff (New Launchers to Work with Windows.Thnx to Autoit!)Game Development ToolsPortes (A Backgammon game)Ball (An Arkanoid Style game)Au3? SecretProgz - Reveals Commands that can be used on your system CleanOut - Uninstall leftovers Enable windows XP Autologon. Stop Windows Auto Sharing your hard drives (C$,D$,etc) D-Link - Create a dynamic link.Useful for server shortcuts Fun - How would your name sounds in Japanese,Russian or Reventian? Fix_srt - Shift a subtitle (.srt) some secs +/- Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 2, 2006 Moderators Share Posted January 2, 2006 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) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now