xtreempje Posted March 18 Share Posted March 18 So Im trying to start shortcuts with proxy and want to save the file output as a variable like $client1 = "C:/shortcut.lnk" what I tried is saving it with iniwrite but then I get a [] in the file wich makes the script return to an error. I also tried : Func Save() If _GUICtrlEdit_GetLine($Edit1, 0) = True Then $FileName = GUICtrlRead($Input1) ;$FileName = @Systemdir & "\mstsc.exe" ; to work with autoit variables $args = '_GUICtrlEdit_GetLine($Edit1, 0) $LinkFileName = GUICtrlRead($Input2) & "\Client1.lnk" $WorkingDirectory = "%windir%" ;$WorkingDirectory = @WindowsDir $Icon = GUICtrlRead($Input1) ;$Icon = @WindowsDir & \system32\SHELL32.dll" $IconNumber = 67 $Description = "Concept Icon" $State = @SW_SHOWMAXIMIZED FileCreateShortcut($FileName, $LinkFileName, $WorkingDirectory, $args, $Description, $Icon,"", $IconNumber, $State) _FileWriteToLine( "Config.au3", 3, "$client1=" & GUICtrlRead($Input2), & '\Client1.lnk"' 1) Endif EndFunc But if the .au3 file is empty it will not write in it. I also tried Filewrite but then It does not replace anything and just add multiple lines with the same variable. I hope someone can help me out, thanks. Link to comment Share on other sites More sharing options...
xtreempje Posted March 19 Author Share Posted March 19 I am trying to get rid of the "[" and "]" in the config file and tried this but still no luck. can anyone help me out? #include<File.au3> $sData = "[" $FileName = "test.txt" $hFile = FileOpen($FileName, 2) FileWrite($hFile, $sData) FileClose($hFile) $hFileOpen = FileOpen($FileName) $ReadData = FileRead($hFileOpen) FileClose($hFileOpen) $sNewFile = StringRegExpReplace($ReadData, '[', '') $sNewFile = StringRegExpReplace($sNewFile, "]", "") $hFileOpen = FileOpen($FileName, 2) FileWrite($hFileOpen, $sNewFile) FileClose($hFileOpen) shellexecute('test.txt') Link to comment Share on other sites More sharing options...
TimRude Posted March 19 Share Posted March 19 FileWrite appends to an existing file. The function description says: Quote Write text/data to the end of a previously opened file. To modify an existing file you should delete the original with FileDelete before FileWrite-ing the changed contents back. Link to comment Share on other sites More sharing options...
xtreempje Posted March 20 Author Share Posted March 20 thanks man this solved it! 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