Jump to content

Users Profile Folders


Recommended Posts

  • Replies 62
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

So you went ahead and compiled it ...

Please run this from the Scite Editor:

#include <file.au3>
Dim $a_users
Dim $s_userfolder = "D:\users\"
_FileReadToArray("users.txt", $a_users)

For $i = 1 To $a_users[0]
    ConsoleWrite("DirCreate(" & $s_userfolder & $a_users[$i] & ")" & @CRLF)
    ConsoleWrite("ICACLS.exe " & $s_userfolder & $a_users[$i] & " /grant " & $a_users[$i] & ":(OI)(CI)(RX,W,DC)" & @CRLF)
Next

Note, I probably forgot to close the DirCreate() Function call.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

yea i saw that is was missing the right bracket , so i closed and re complied it , and ran it and it crashed my system .. it just kept opening them and opening ..

this one doesnt work either Hannes sorry to say ..

errors out with "incorrect number of parameters in function call"

well if i take out the Msgbox , it runs so quick i cant see it , but nothing happens .. no folder made or anything ...

#include <file.au3> 

Dim $a_users 
Dim $s_userfolder = "c:\" 
_FileReadToArray("test.txt", $a_users)  

For $i = 1 To $a_users[0]     
ConsoleWrite("DirCreate(" & $s_userfolder & $a_users[$i] & ")" & @CRLF)     
ConsoleWrite("ICACLS.exe " & $s_userfolder & $a_users[$i] & " /grant " & $a_users[$i] & ":(OI)(CI)(RX,W,DC)" & @CRLF) 

Next   

MsgBox(0, "Done")
Edited by startrek133
Link to comment
Share on other sites

Hello Startrek,

please skip the compilation, because then you have very less possibilities to debug your script. Have you installed SciTe4AutoIT? Because then you can run the scripts by pressing "F5".

The output will be shown in the lower pane.

Secondly the wrong function call is caused by your MsgBox(). If you'd run it in Scite you would have seen this output:

C:\Users\hannes\Desktop\New AutoIt v3 Script.au3(9,17) : ERROR: MsgBox() [built-in] called with wrong number of args.
MsgBox(0, "Done")
~~~~~~~~~~~~~~~~^
This shows you directly what is wrong. :mellow:
Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Okay let's go slow:

1. create a new Folder under your C:\ drive called "test"

2. Edit the ACL of that folder by the following:

Under Advanced settings:

Break the inheritance and copy the settings from the parent foler (in this case C:\)

Remove all ACL settings Except the FullControls of Administrators and SYSTEM

Under "Normal Settings":

Add the "Users" group and greant them "ListFolder" rights only

Under Advanced settings:

Change the inheritance of the Users Group to "This folder only"

3. Compile and run this script:

#RequireAdmin
#AutoIt3Wrapper_Change2CUI=y
#include <file.au3>
Dim $a_users
Dim $s_userfolder = "c:\test\"
_FileReadToArray("test.txt", $a_users)
For $i = 1 To $a_users[0]
    ConsoleWrite(DirCreate( $s_userfolder & $a_users[$i]) & @CRLF)
    RunWait("ICACLS.exe " & $s_userfolder & $a_users[$i] & " /grant test:(OI)(CI)(RX,W,DC)")
Next
MsgBox(0,"Done","Check Console output!")

Tell me what's your output!

.. And nobody said you'd be an idiot at all.

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

well i tired every different way I know of to get that array to work and still the same issue , it will make the folder , but will not set any of the security settings or permissions ..

and for some reason even putting END after the WEnd the script still runs and i have to right click on it to exit it out ..

never though it would be this hard .. here are the different ways i tried the array with no luck ..

You're supposed to put END at the end of the text file not the script

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco Finesse, Github, IRC UDF, WindowEx UDF

 

Link to comment
Share on other sites

You're supposed to put END at the end of the text file not the script

Sorry Rcmaehl

been getting confused with everyone saying try Icacls, or just the cacls .. but still cant get yours to work .. when i sub out "c:\username" for the array , it will make the folder , i get the pop up that says everything is done .. but when i get the folder nothing was set :mellow:

Link to comment
Share on other sites

Sorry Hannes, didn't work again .. in fact is crashed my system again .. hit f5 to run the script and open hundreds of them again and crashed ..

plus not sure why i have to make the folder and set the permission , that is the whole point of this is to make the users folder and set the permissions .. the trouble seems to be when i try to use the txt file with the list of usernames ..

but thanks for the help ..

Link to comment
Share on other sites

Maybe it would be a good start by using 5 to 10 test entries in your input file instead of 200.

Well setting this rights is to ensure that the users do not get the right to see each other's files.

If you are in a domain enviroment and want to set rights to the domain users you need to write the user name like mydomain\username .

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

I only have 1 entry in the test file right now ... nothing else ..

yea i know that part, once i get everything working i will be switching a lot of the c:\ stuff to \\servername\profile and changing the "username" to \\domain\username ..

my goal was to first get it working on my computer before i started playing around with live servers and users ..

but if i have to manual go set every folder that this program makes then it's pointless to keep going .. the whole point so for this script to do it for me .. its easy to have the script make all the folders ..

thanks

Link to comment
Share on other sites

I'm trying to figure it out myself. I've been screwing around with my script for a while. Can you run this and paste the console output:

#include <File.au3>

;Making of the folders from a txt file;

Global $User, $Line

$Line = 1

While 1
    $User = FileReadLine("test.txt", $Line)
    If Not ($User == "END") Then
        DirCreate("c:\"&"\"&$User)
        $Line += 1
    Else
        MsgBox(0x0, "Done", "END Encountered, Script is Done.")
        Exit(0)
    EndIf

    ; Removing the Inheritance Flag ;

    RunWait(@ComSpec & ' /c c:\XCACLS.vbs "' & $USER & '" /I Copy', @ScriptDir, @SW_HIDE)
    ConsoleWrite(@ComSpec & ' /c c:\XCACLS.vbs "' & $USER & '" /I Copy', @ScriptDir, @SW_HIDE)

    ; deleting "users" from the folder;

    RunWait(@ComSpec & ' /c c:\XCACLS.vbs "' & $USER & '" /E /T /R "local\Users"', @ScriptDir, @SW_HIDE)
    ConsoleWrite(@ComSpec & ' /c c:\XCACLS.vbs "' & $USER & '" /E /T /R "local\Users"', @ScriptDir, @SW_HIDE)

    ; give admins owernship ;

    RunWait(@ComSpec & ' /c c:\subinacl /subdirectories "' & $USER & '" /setowner="Administrator"', @ScriptDir, @SW_HIDE)
    ConsoleWrite(@ComSpec & ' /c c:\subinacl /subdirectories "' & $USER & '" /setowner="Administrator"', @ScriptDir, @SW_HIDE)

     ; give myself full controll ;

    RunWait(@ComSpec & ' /c c:\XCACLS.vbs "' & $USER & '" /E /T /G domain\username:F', @ScriptDir, @SW_HIDE)
    ConsoleWrite(@ComSpec & ' /c c:\XCACLS.vbs "' & $USER & '" /E /T /G domain\username:F', @ScriptDir, @SW_HIDE)

     ; give user full controll ;

    RunWait(@ComSpec & ' /c c:\XCACLS.vbs "' & $USER & '" /E /T /G domain\username:F', @ScriptDir, @SW_HIDE)
    ConsoleWrite(@ComSpec & ' /c c:\XCACLS.vbs "' & $USER & '" /E /T /G domain\username:F', @ScriptDir, @SW_HIDE)
    
WEnd
Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco Finesse, Github, IRC UDF, WindowEx UDF

 

Link to comment
Share on other sites

still no luck Rcmaehl

i pasted it in and hit F5 to run it and errors out at the ConsoleWrite command part ..

>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "\\my docs\Folder Maker\test.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams

+>08:11:57 Starting AutoIt3Wrapper v.2.0.3.0 Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 3  CPU:X64 OS:X86)

>Running AU3Check (1.54.19.0)  from:C:\Program Files\AutoIt3 

\\my docs\Folder Maker\test.au3(22,94) : ERROR: ConsoleWrite() [built-in] called with wrong number of args.     

ConsoleWrite(@ComSpec & ' /c c:\XCACLS.vbs "' & $USER & '" /I Copy', @ScriptDir, @SW_HIDE) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 
\\my docs\Folder Maker\test.au3 - 1 error(s), 0 warning(s) 

!>08:11:57 AU3Check ended.rc:2 
>Exit code: 0    Time: 0.753
Edited by startrek133
Link to comment
Share on other sites

I totally failed there. I forgot to copy the entire runwait commands into the consolewrites.

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco Finesse, Github, IRC UDF, WindowEx UDF

 

Link to comment
Share on other sites

huh at least you know what your talking about , i was tiring to look up with the consolewrite command did and find examples and its slow going .. i hate how they don't teach you any of this at school!!!!!!

O_o You learned autoit at school!?

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco Finesse, Github, IRC UDF, WindowEx UDF

 

Link to comment
Share on other sites

PLEASE! Change $s_basefolder and $s_inputfile, compile the script and run it. I tested it and it runs good.

#AutoIt3Wrapper_Change2CUI=y
#include <file.au3>

Dim $s_basefolder = "C:\Test"
Dim $s_inputfile = "C:\jobs\users.txt"
Dim $a_users

DirCreate($s_basefolder)

RunWait("icacls.exe " & $s_basefolder &  " /inheritance:d")
RunWait("icacls.exe " & $s_basefolder &  ' /remove:g "CREATOR OWNER"')
RunWait("icacls.exe " & $s_basefolder &  ' /remove:g "BUILTIN\Users"')

_FileReadToArray($s_inputfile, $a_users)

For $i = 1 To $a_users[0]
    DirCreate($s_basefolder & "\" & $a_users[$i] )
    RunWait("icacls.exe " & $s_basefolder & "\" & $a_users[$i] & " /grant " & $a_users[$i] & ":(OI)(CI)(RX,W,DC)")
Next

It isn't that hard to understand, is it?

Edited by Hannes123
Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

No I wish , we had it would have come in handy seeing how in the world of IT , you can make your life easier by script things out .. that is if you understand program code and stuff like that .. i tried for a week to write this up before posting on .. I just hope it can be done , because i really don't want to have to hand type out 200+ folders and then set all the permissions ..

Link to comment
Share on other sites

PLEASE! Change $s_basefolder and $s_inputfile, compile the script and run it. I tested it and it runs good.

#AutoIt3Wrapper_Change2CUI=y
#include <file.au3>

Dim $s_basefolder = "C:\Test"
Dim $s_inputfile = "C:\jobs\users.txt"
Dim $a_users

DirCreate($s_basefolder)

RunWait("icacls.exe " & $s_basefolder &  " /inheritance:d")
RunWait("icacls.exe " & $s_basefolder &  ' /remove:g "CREATOR OWNER"')
RunWait("icacls.exe " & $s_basefolder &  ' /remove:g "BUILTIN\Users"')

_FileReadToArray($s_inputfile, $a_users)

For $i = 1 To $a_users[0]
    DirCreate($s_basefolder & "\" & $a_users[$i] )
    RunWait("icacls.exe " & $s_basefolder & "\" & $a_users[$i] & " /grant " & $a_users[$i] & ":(OI)(CI)(RX,W,DC)")
Next

It isn't that hard to understand, is it?

O_o *Facepalms at his own stupidity.* Why didn't I think of that. Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco Finesse, Github, IRC UDF, WindowEx UDF

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...