Guest marno Posted September 28, 2005 Share Posted September 28, 2005 Hi, i have a prog 1.exe and a file 1.txt i want to do this : For $i = 1 to 24 Step 1 If FileExists("c:\WINNT\$i.txt") then ; Nothing else FileCopy ( '\\Serveur\TEMP\$i.txt','c:\WINNT',0) RunWait("\\Serveur\SECURITE\$i.exe -u", "\\Serveur\SECURITE", @SW_HIDE) endif Next I have an error msg : can't find \\Serveur\SECURITE\$i.exe The script try to start $i.exe and not 1.exe Link to comment Share on other sites More sharing options...
Valuater Posted September 28, 2005 Share Posted September 28, 2005 ok step by step... For $i = 1 to 24 Step 1 ; bla... bla Next will do 24 files... do you only have 1 exe and 1 text file???? 8) Link to comment Share on other sites More sharing options...
Guest marno Posted September 28, 2005 Share Posted September 28, 2005 ok step by step...For $i = 1 to 24 Step 1 ; bla... bla Nextwill do 24 files...do you only have 1 exe and 1 text file????8)yes i have 24 text files and 24 exe Link to comment Share on other sites More sharing options...
Valuater Posted September 28, 2005 Share Posted September 28, 2005 Hi,i have a prog 1.exe and a file 1.txti want to do this : For $i = 1 to 24 Step 1 If FileExists("c:\WINNT\$i.txt") then; Nothing else FileCopy ( '\\Serveur\TEMP\$i.txt','c:\WINNT',0) RunWait("\\Serveur\SECURITE\$i.exe -u", "\\Serveur\SECURITE", @SW_HIDE) endifNextI have an error msg : can't find \\Serveur\SECURITE\$i.exeThe script try to start $i.exe and not 1.exe this states that your looking at a file and if it existsIf FileExists("c:\WINNT\$i.txt") thenbut... then you try to copy from another source to the one you checkedFileCopy ( '\\Serveur\TEMP\$i.txt','c:\WINNT',0)maybe you have it reversed and want thisFileCopy ( "source", "dest" [, flag] )FileCopy ( 'c:\WINNT', '\\Serveur\TEMP\$i.txt',0)????8) Link to comment Share on other sites More sharing options...
Guest marno Posted September 28, 2005 Share Posted September 28, 2005 this states that your looking at a file and if it existsIf FileExists("c:\WINNT\$i.txt") thenbut... then you try to copy from another source to the one you checkedFileCopy ( '\\Serveur\TEMP\$i.txt','c:\WINNT',0)maybe you have it reversed and want thisFileCopy ( "source", "dest" [, flag] )FileCopy ( 'c:\WINNT', '\\Serveur\TEMP\$i.txt',0)????8)My source : \\serveur\TEMP\1 .... 24.txtI want to make a script which permit me to install 24 Updates. Some update need a reboot so i need to test. Link to comment Share on other sites More sharing options...
Valuater Posted September 28, 2005 Share Posted September 28, 2005 (edited) this FileCopy ( '\\Serveur\TEMP\$i.txt','c:\WINNT',0) should be this FileCopy ( '\\Serveur\TEMP\$i.txt','c:\WINNT\',0) AND.... this copies ALL FILES in the source to the destination FileCopy("C:\old\*.*", "C:\new\") thus this copies ALL TEXT FILES FileCopy("C:\old\*.txt", "C:\new\") if you can use this there is no need for For $i = 1 to 24 Step 1 ; bla... bla Next 8) Edited September 28, 2005 by Valuater Link to comment Share on other sites More sharing options...
drak Posted September 28, 2005 Share Posted September 28, 2005 (edited) your main problem is here If FileExists("c:\WINNT\$i.txt") then should be If FileExists("c:\WINNT\" & $i & ".txt") then and here RunWait("\\Serveur\SECURITE\$i.exe -u", "\\Serveur\SECURITE", @SW_HIDE) should be RunWait("\\Serveur\SECURITE\" & $i & ".exe -u", "\\Serveur\SECURITE", @SW_HIDE) Edit: forgot the filecopy one FileCopy ( '\\Serveur\TEMP\$i.txt','c:\WINNT',0) should be FileCopy ( '\\Serveur\TEMP\" & $i & ".txt','c:\WINNT',0) Edited September 28, 2005 by drak Link to comment Share on other sites More sharing options...
Valuater Posted September 28, 2005 Share Posted September 28, 2005 Good catch drak.... I should have spotted that right away @#%...Dah.... 8) Link to comment Share on other sites More sharing options...
drak Posted September 28, 2005 Share Posted September 28, 2005 I'm surprise, Valuater your usually faster than that having a slow day perhaps ? Link to comment Share on other sites More sharing options...
Guest marno Posted September 28, 2005 Share Posted September 28, 2005 Thx a lot !!!!!But for this FileCopy ( '\\Serveur\TEMP\$i.txt','c:\WINNT',0)should beFileCopy ( '\\Serveur\TEMP\" & $i & ".txt','c:\WINNT',0)should beFileCopy ("\\Serveur\TEMP\" & $i & ".txt", "c:\WINNT\",0)Fine i love autoit !!! Link to comment Share on other sites More sharing options...
MrSpacely Posted September 28, 2005 Share Posted September 28, 2005 (edited) Funny how people read over simple mistakes I saw it instantly but that because I ate loads of sugar. Final and short For $i = 1 to 24;changed step 1 default is 1 not nessesary If Not FileExists("c:\WINNT\" & $i & ".txt") then; just use NOT (not else here) FileCopy ( '\\Serveur\TEMP\' & $i & '.txt','c:\WINNT',0) RunWait("\\Serveur\SECURITE\" & $i & ".exe -u", "\\Serveur\SECURITE", @SW_HIDE) endif Next Please read syntax rules first its not PHP code so variables need to be outside of " " or ' ' Edited September 28, 2005 by MrSpacely 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