StMaSi Posted February 15, 2017 Share Posted February 15, 2017 I'm trying to create a file on a network share, from a Windows 10 computer, but for whatever reason, I'm unable to do so. The file just isn't created. In addition, if I manually create the file myself and simply try to append data to it, that doesn't work either. The network share in question is completely unrestricted and all domain users have full control. Whether I use this to attempt to create a file... _FileCreate('"' & @ScriptDir & '\filename.txt' & '"') Or this to attempt to append to an existing file... FileWriteLine('"' & @ScriptDir & '\filename.txt' & '"', "This is a test." & @CRLF) Neither work. Can anyone assist with this? Thanks in advance. Link to comment Share on other sites More sharing options...
Subz Posted February 15, 2017 Share Posted February 15, 2017 (edited) Use FileOpen function first with the flag set to 1 first for example: $hFileOpen = FileOpen(@ScriptDir & '\Filename.txt', 9) FileWrite($hFileOpen, 'This is a test') Edited February 15, 2017 by Subz Changed flag Link to comment Share on other sites More sharing options...
StMaSi Posted February 15, 2017 Author Share Posted February 15, 2017 Yup, did that, but still no-go. Using FileOpen and FileClose before and after. Thanks. Link to comment Share on other sites More sharing options...
Subz Posted February 15, 2017 Share Posted February 15, 2017 Can you try the code above? Link to comment Share on other sites More sharing options...
spudw2k Posted February 15, 2017 Share Posted February 15, 2017 You are calling out @ScriptDir...so the script is executing from said network share, yes? Just double-checking. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
StMaSi Posted February 15, 2017 Author Share Posted February 15, 2017 Here's exactly what's happening... $mdate = StringReplace(_NowCalcDate(), "/", "") $mtime = StringReplace(_NowTime(5), ":", "") $mfile = @ComputerName & "." & $mdate & "." & $mtime & ".txt" $file = FileOpen('"' & @ScriptDir & '\' & $mfile & '"', 9) FileWrite($file, "This is a test.") FileClose($file) However, no file creation and no errors encountered. Thanks again. Link to comment Share on other sites More sharing options...
Subz Posted February 15, 2017 Share Posted February 15, 2017 (edited) You should run this code within Scite and you'll notice that you have errors in the naming. Brain fade, should go to bed, this works for me on UNC using Windows 10 x64 #include <Date.au3> $mdate = StringReplace(_NowCalcDate(), "/", "") $mtime = StringReplace(_NowTime(5), ":", "") $mfile = @ComputerName & "." & $mdate & "." & $mtime & ".txt" ConsoleWrite($mfile & @CRLF) $file = FileOpen(@ScriptDir & '\' & $mfile, 9) FileWrite($file, "This is a test.") FileClose($file) Edited February 15, 2017 by Subz Link to comment Share on other sites More sharing options...
spudw2k Posted February 15, 2017 Share Posted February 15, 2017 What is the path of the share? Is it a mapped drive or UNC path? If it's a mapped drive, are you elevating the script or using #RequireAdmin? You should also check $file to make sure it actually returned the handle, else FileWrite and Close will fail. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Subz Posted February 15, 2017 Share Posted February 15, 2017 Updated my post above, the issue was the quotes you have around the filename, it was attempting to create the file '"ComputerName.Date.Time.txt"'. Link to comment Share on other sites More sharing options...
StMaSi Posted February 15, 2017 Author Share Posted February 15, 2017 19 minutes ago, Subz said: You should run this code within Scite and you'll notice that you have errors in the naming. Brain fade, should go to bed, this works for me on UNC using Windows 10 x64 #include <Date.au3> $mdate = StringReplace(_NowCalcDate(), "/", "") $mtime = StringReplace(_NowTime(5), ":", "") $mfile = @ComputerName & "." & $mdate & "." & $mtime & ".txt" ConsoleWrite($mfile & @CRLF) $file = FileOpen(@ScriptDir & '\' & $mfile, 9) FileWrite($file, "This is a test.") FileClose($file) This worked! Thank you very much!!! Link to comment Share on other sites More sharing options...
Subz Posted February 15, 2017 Share Posted February 15, 2017 Before I go just wanted to point out you could use $mfile = @ComputerName & '.' & @Year & @Mon & @MDay & '.' & @Hour & @Min & @Sec & '.txt' 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