shornw Posted July 12, 2006 Share Posted July 12, 2006 hi all Is there an AutoIt command that can identify the .bat filename that calls a script. We have about 40 Logonscripts, some of which are redundant, and I want to identify which are being used. I can do it by creating a seperate log for each one but it would be much easier to have just one log file. @ScriptName calls the name of the script running but I need the name of the file that has called the script. Any help always appreciated Thx [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font] Link to comment Share on other sites More sharing options...
Briegel Posted July 12, 2006 Share Posted July 12, 2006 Why don't you call the script with parameter %filename of batch%? Then you can use in the script '$CmdLine[]' to get the filename from calling batch. Link to comment Share on other sites More sharing options...
shornw Posted July 12, 2006 Author Share Posted July 12, 2006 Sorry if I'm being thick here but I dont quite understand what you mean. could you explain a little more. Thanks [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font] Link to comment Share on other sites More sharing options...
/dev/null Posted July 12, 2006 Share Posted July 12, 2006 you could retrieve the parent process ID of the running process with WMI. However, the parent process name will allways be cmd.exe in case of a batch file, so you won't get the name of the calling batch file. Sample of my test (I ran process.exe from run.bat). Caption: process.exe CommandLine: process.exe Name: process.exe ParentProcessId: 5904 ProcessId: 2696 Caption: cmd.exe Name: cmd.exe ParentProcessId: 3652 ProcessId: 5904 Better do this: Add the following line at the beginning of each batch file and then analyze the log. echo %DATE% - %TIME% - %0% >> \\serverxzy\logs\batch-execute.log Users must have write access to that file !! Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
/dev/null Posted July 12, 2006 Share Posted July 12, 2006 Sorry if I'm being thick here but I dont quite understand what you mean. could you explain a little more. Thanks what he means is: run.bat: AutoITScript.exe %0% This will call your compiled AutoIT script with the name of the batch file. Then you can write that name into a log within the AutoIT script. AutoITScript.au3: $calling_batch = $CmdLine[1] FileWriteLine("C:\bitches.log",$calling_batch) !! You'll have to add some error checking as well !! Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
shornw Posted July 12, 2006 Author Share Posted July 12, 2006 Guys...what can I say. Absolutely fantastic...all these years of IT and i didnt know about the %0% All done and working... Thank you so much, this will make life a lot easier for me [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font] Link to comment Share on other sites More sharing options...
mike1305 Posted July 19, 2006 Share Posted July 19, 2006 what he means is: run.bat: AutoITScript.exe %0% This will call your compiled AutoIT script with the name of the batch file. Then you can write that name into a log within the AutoIT script. AutoITScript.au3: $calling_batch = $CmdLine[1] FileWriteLine("C:\bitches.log",$calling_batch) !! You'll have to add some error checking as well !! Cheers Kurt I couldn't help but note the irony. Amp Energy Drink: the official sponsor of me scripting at 2AM. Link to comment Share on other sites More sharing options...
/dev/null Posted November 6, 2006 Share Posted November 6, 2006 I couldn't help but note the irony. that was intentional!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * 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