Chimaera Posted June 12, 2011 Share Posted June 12, 2011 im knocking together a little attribute and permissions GUI basically for customer drives that have been caught with the latest security virus that hides everything and changes stuff starting with $source = FileSelectFolder("Select Drive" , "") so the attrib section is done basically just using FileSetAttrib( $source & "Users", "-H", 1); basically just unhides the folder Users and sub folders now on the permssion side i have used RunWait(@ComSpec & "/c" & 'takeown /f $source & "*.*"'); equivalent to C:\*.* if C were chosen RunWait(@ComSpec & "/c" & 'ICALCS $source & "*.*" /grant @UserName:F'); equivalent to C:\*.* grant current logged on user full permissions 1: So first question is this the right way to do this? 2: I have hit a snag because with file select folder if i click C drive it gives a result of C:\ but if i select c:\users folder it gives a result of C:\Users with no backslash How do i get it to either add the backslash for all selections with FileSelectFolder So i get C:\ or C:\Users\ so that *.* fits on the end of either Or is there a way to just get the drive letter and ill add the rest like this & :\ & Hope this makes sense Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
JohnOne Posted June 12, 2011 Share Posted June 12, 2011 Maybe you should test it for the backslash with if then, using StringRight function. If its not there, add it. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Chimaera Posted June 12, 2011 Author Share Posted June 12, 2011 (edited) Thanks JohnOne I ended up with this $var = StringRight( $source, 1) if $var = "\" Then $source = StringTrimRight( $source , 1) EndIf Chimaera Edited June 12, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
JohnOne Posted June 12, 2011 Share Posted June 12, 2011 (edited) Or maybe If Not StringRight( $source, 1) == "\" Then $source &= "\" EndIf Edited June 12, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
GEOSoft Posted June 12, 2011 Share Posted June 12, 2011 Or my old favorite $Source = StringRegExpReplace($Source, "\134*$", "\\", 1) It will add \ if it's not there and it will replace single or multiple occurences like \\ but only at the end of the string. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
guinness Posted June 12, 2011 Share Posted June 12, 2011 And another I found whilst searching in File.au3, just check out _GetDirectoryFormat() in my Signature. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Chimaera Posted June 12, 2011 Author Share Posted June 12, 2011 Or my old favorite $Source = StringRegExpReplace($Source, "\134*$", "\\", 1) It will add \ if it's not there and it will replace single or multiple occurences like \\ but only at the end of the string. And the winner is GEOSoft, i have no idea "how" it does it but very clever Thanks for the help Chim If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Chimaera Posted June 15, 2011 Author Share Posted June 15, 2011 (edited) Can someone advise on if i have got these laid out correctly plz Starting with $source = FileSelectFolder("Select Drive", "C:") ;<<< just for eg $source = StringRegExpReplace($source, "\134*$", "\\", 1) ;<<< just for eg Giving me C:\ for eg Then RunWait(@ComSpec & "/c takeown /f" & $source & "/r") ;<<< is the syntax correct? RunWait(@ComSpec & "/c ICALCS" & $source & "*.*" & "/grant @UserName:F") ;<<< is the syntax correct? As far as i can tell its correct but doesn't seem to work, well it finishes far too quick can someone just check it for me plz Many thanks Edited June 15, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Joon Posted June 15, 2011 Share Posted June 15, 2011 (edited) I haven't check on the executable syntax but I know you're missing spaces on before and after the quotes. I also recommend using single quote and put double quotes around $source for the long file names. RunWait(@ComSpec & " /c takeown /f " & $source & " /r"); RunWait(@ComSpec & " /c ICALCS " & $source & " *.*" & " /grant @UserName:F"); - joon Edited June 15, 2011 by Joon Link to comment Share on other sites More sharing options...
Chimaera Posted June 15, 2011 Author Share Posted June 15, 2011 (edited) aah getting closer it opened a cmd window but just sat there with the cursor in the corner.if i do it manually like this in a cmd windowtakeown /f C:\ /rit works fine Edited June 15, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Joon Posted June 15, 2011 Share Posted June 15, 2011 aah getting closer it opened a cmd window but just sat there with the cursor in the corner. if i do it manually like this in a cmd window it works fine hmm... can you change your code to something like this and see the console output? $syntax = " /c takeown /f " & $source & " /r" ConsoleWrite($syntax & @LF) RunWait(@ComSpec & $syntax); Link to comment Share on other sites More sharing options...
Chimaera Posted June 15, 2011 Author Share Posted June 15, 2011 (edited) Here you go all seems to be correct and copied from console/c takeown /f C:\ /rand again window open with no text and cursor sat in corner Edited June 15, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Joon Posted June 15, 2011 Share Posted June 15, 2011 Here you go all seems to be correct and copied from console and again window open with no text and cursor sat in corner This works for me without a problem. $syntax = " /c takeown /f C:\temp /r" ConsoleWrite($syntax & @LF) RunWait(@ComSpec & $syntax) Link to comment Share on other sites More sharing options...
Chimaera Posted June 15, 2011 Author Share Posted June 15, 2011 (edited) This works for me without a problem. $syntax = " /c takeown /f C:\temp /r" ConsoleWrite($syntax & @LF) RunWait(@ComSpec & $syntax) Ok i cant see what the hell is wrong here. Edited June 15, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Joon Posted June 15, 2011 Share Posted June 15, 2011 Your code worked on me without any modification. Windows 7 Enterprise x64. Link to comment Share on other sites More sharing options...
GEOSoft Posted June 15, 2011 Share Posted June 15, 2011 You could be running into a permissions problem try adding " /d y" to the end of $syntax Also I don't remember what happens if you attempt takeown on a folder where you already have ownership. I've been playing with takeown in some code of mine and it works fine. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Chimaera Posted June 15, 2011 Author Share Posted June 15, 2011 (edited) So the Permissions button didnt give a blank window?, im on same OS as you m8 Another odd thing for me, when the blank cmd is open you can press enter and the cursor moves down a line?? EDIT after addy GEOSoft addition it now flashes the cmd window and exits, ill have to test it on a machine where the ownership is different to see whats happening Thanks for the help Edited June 15, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
UEZ Posted June 15, 2011 Share Posted June 15, 2011 Just a hint: you can also use SubInACL to change ownership of files and folders.Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Chimaera Posted June 15, 2011 Author Share Posted June 15, 2011 (edited) Just a hint: you can also use SubInACL to change ownership of files and folders.Br,UEZThanks UEZbut...i messed with it a few years ago and its far to complicated for me to use, whilst i agree its the most powerfull but the help is also limitedand i have no idea how to start it through autoit And it dosent seem to support Vista or above on the page you mentioned Edited June 15, 2011 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Maffe811 Posted June 15, 2011 Share Posted June 15, 2011 This works for me without a problem. $syntax = " /c takeown /f C:\temp /r" ConsoleWrite($syntax & @LF) RunWait(@ComSpec & $syntax) The cmd window flashes for me on Win7 HomePremium 64-bit [font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler] 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