tobi Posted March 13, 2006 Posted March 13, 2006 Hi everybody ! I am trying to add one entry to the services file in C:\...\system32\drivers\etc . i open this file with notepad and i use the send command to add some more lines. my problem is that i cant find out how add my lines behind the existing lines... Here is the code i use: RunAsSet ( "administrator",@Computername, "****", 1 ) Run( "Notepad.exe C:\WINDOWS\system32\drivers\etc\services", "C:\Windows", @SW_MAXIMIZE) WinWaitActive("services - Notepad") Send("bla bla bla") WinClose("services - Notepad") WinWaitActive("Notepad") Send("!n") RunAsSet () I also tried it with FileWriteLine and then it automatically adds my stuff at the end of the existing lines. But i couldnt use this script with RunAsSet, which is requiered. have anyone some ideas to help me ? Thx in advance br, Tobi
BigDod Posted March 13, 2006 Posted March 13, 2006 Hi everybody ! I am trying to add one entry to the services file in C:\...\system32\drivers\etc . i open this file with notepad and i use the send command to add some more lines. my problem is that i cant find out how add my lines behind the existing lines... Here is the code i use: RunAsSet ( "administrator",@Computername, "****", 1 ) Run( "Notepad.exe C:\WINDOWS\system32\drivers\etc\services", "C:\Windows", @SW_MAXIMIZE) WinWaitActive("services - Notepad") Send("bla bla bla") WinClose("services - Notepad") WinWaitActive("Notepad") Send("!n") RunAsSet () I also tried it with FileWriteLine and then it automatically adds my stuff at the end of the existing lines. But i couldnt use this script with RunAsSet, which is requiered. have anyone some ideas to help me ? Thx in advance br, TobiTry RunAsSet ( "administrator",@Computername, "****", 1 ) Run( "Notepad.exe C:\WINDOWS\system32\drivers\etc\services", "C:\Windows", @SW_MAXIMIZE) WinWaitActive("services - Notepad") Send("^{END}") Send("{ENTER}") Send("bla bla bla") WinClose("services - Notepad") WinWaitActive("Notepad") Send("!n") RunAsSet () Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother
Developers Jos Posted March 13, 2006 Developers Posted March 13, 2006 What about doing it without the need for Notepad: RunAsSet ( "administrator",@Computername, "****", 1 ) Run(@comspec & " /c ECHO bla bla bla >> C:\WINDOWS\system32\drivers\etc\services", "C:\Windows", @SW_HIDE) RunAsSet () 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.
Moderators SmOke_N Posted March 13, 2006 Moderators Posted March 13, 2006 This worked for me:RunAsSet( "administrator",@Computername, "****", 1 ) FileWriteLine(@SystemDir & '\drivers\etc\services', 'Testing---------------------------------------') TestTheory() RunAsSet() Func TestTheory() Run( "Notepad.exe " & @SystemDir & "\drivers\etc\services", "C:\Windows", @SW_MAXIMIZE) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
cdkid Posted March 13, 2006 Posted March 13, 2006 In the latest beta, there's a UDF of mine called _FileWriteToLine, that's probably what you're lookin for. ~cdkid AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Moderators SmOke_N Posted March 13, 2006 Moderators Posted March 13, 2006 In the latest beta, there's a UDF of mine called _FileWriteToLine, that's probably what you're lookin for.~cdkidYou don't need a UDF, it's a one liner. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Valuater Posted March 13, 2006 Posted March 13, 2006 In the latest beta, there's a UDF of mine called _FileWriteToLine, that's probably what you're lookin for.~cdkidooohhh... your in the beta... way to go cdkid8)
Moderators SmOke_N Posted March 13, 2006 Moderators Posted March 13, 2006 ooohhh... your in the beta... way to go cdkid8)I didn't comprehend that!! WTG!! (P.S., I did like the UDF) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
cdkid Posted March 13, 2006 Posted March 13, 2006 thanks ~cdkid AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Developers Jos Posted March 13, 2006 Developers Posted March 13, 2006 (edited) Seems your are all missing the issue that the OP needs elivated rights to do this, at least that what I assume since there is a RunASSet() in the original post. Thats why I proposed the one-liner using Run(). Edited March 13, 2006 by JdeB 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.
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