gurellaz696 Posted November 4, 2019 Share Posted November 4, 2019 Hi guys, Wondering if you can help, basically trying to get a log of all computers with or without SSD. I've created this and stuck on trying to see if the file already exists. #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <file.au3> ; Check the SSD status for C:\ Local $Name= @ComputerName Local $SSD= DriveGetType("C:\", $DT_SSDSTATUS) Local $Network= "\\nashom04\hdsource\SSD" Local $iFileExists = FileExists($Name & ".txt") FileChangeDir($Network) MsgBox(0,"TEST", $iFileExists) If $iFileExists Then FileWrite($Name&'.txt', $Name&' '&$SSD) MsgBox(0,"Thank You", $Name & " has been updated.") Exit Else FileWrite($Name&'.txt', $Name&' '&$SSD) MsgBox(0,"Thank You", $Name & " has been updated.") EndIf What it's meant to do check the hard drive if it's a SSD or not and write a text file into a network directory. All is good, however if I want to check if the user has already run the program or not, I use file exists. Running into trouble trying to get it working, it keeps writing even if it exists. Thanks for your help. Link to comment Share on other sites More sharing options...
TheXman Posted November 4, 2019 Share Posted November 4, 2019 (edited) You write the file to the network share. Your check for the existence of the file checks whether it exists in the script's directory because you haven't changed directories yet. So of course the file never exists in the script's directory. You would be much better off using absolute paths instead of relative paths. Then things like that wouldn't happen when changing directories. Edited November 5, 2019 by TheXman Fixed a typo gurellaz696 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
spudw2k Posted November 4, 2019 Share Posted November 4, 2019 Since you have the FileWrite and Msgbox in both conditions, it writes the file. You should be able to remove the first set and just have Exit in the condition check. Alternatively, you could change the logic and reduce a couple lines. If Not $iFileExists Then FileWrite($Name&'.txt', $Name&' '&$SSD) MsgBox(0,"Thank You", $Name & " has been updated.") EndIf gurellaz696 1 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 Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool 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...
gurellaz696 Posted November 4, 2019 Author Share Posted November 4, 2019 Thank you guys, working flawlessly now. Link to comment Share on other sites More sharing options...
JCD Posted December 11, 2021 Share Posted December 11, 2021 I wish to check if details.txt exists so I can use an include and run my script if it does not exist I wish to create it along with (lets say) 2 variables; $USERNumber and $USERName that the user will type in in a popup window like What is the Number and What is the Full Name and then go on running my script any ideas? Link to comment Share on other sites More sharing options...
spudw2k Posted December 13, 2021 Share Posted December 13, 2021 Hi @JCD Please take note that you posted on an old topic (over two years old). It is best-forum-practice to start a new topic even though the topic is similar, unless you are adding to the original post topic. You might check out the INI functions in the help file. You can use those to write to and read from an INI test file. By reading from it you can assigned retrieved values to variables in your script. So, you can use the same FileExists If logic and if it does not exist then create the file and populate it with the desired data. 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 Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool 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...
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