Jump to content

Recommended Posts

Posted

Not sure if this should be here or the coding forum, so I'm chancing here.

 

I now have my little GUI exe created that I've been working on in AutoIT.

Some of the commands use psexec.exe so for the GUI to run properly it needs to be in the same folder as psexec.exe

I know there are tools out there to put two exe's in to one but most are virii writing tools that hide trojans etc so a majority of AV software will now pick it up as infected.

 

Basically I just want to have one exe that I can carry around. Preferably open source software if possible.

 

Any ideas?

 

Thanks :D

Posted

You can include other files in a compiled AutoIT exe using FileInstall.

 

Or you could put all the files you need in a self-extracting archive and have AutoIT run apps from the 'working directoy' once extracted.

Posted

**EDIT**

 

OK I got it to work with the FileInstall. But the help doesn't say anything about it deleting files after use. I don't want it leaving psexec.exe in a folder once I'm done with it.

I guess I could tell it to delete the file as the script ends with FileDelete ()

 

Thankya for the advice :)

Posted
You'll have to specify the full path to the EXE when running it. Perhaps set the path in a global variable, and concatenate it in the FileInstall function and the Run function later on.
Posted

Hmmm weird, I created a test script with this:

 

FileInstall( "c:\pstools\psexec.exe", "",)

MsgBox(0, "DONE", "psexec extracted" )

FileDelete( @WorkingDir & "\psexec.exe")

 

Ran it, and it extracts the exe, after I click OK it deletes it, all perfect how I want it.

I put the install and delete lines in my script, and it goes t*ts up.

Doesn't even extract psexec.

 

I have a feeling it's probably me putting the install line in the wrong place (hopefully).

If it works that should be that sorted.

 

Thankfully I still have the old sysinternals pstools and not the MS owned ones, which I think need you to use /accepteula as a switch for every tool if you want it to run without needing to click yes each time you run it!

Posted

I think it's me being a numpty :p

 

I put the install line further down and it worked. I then put the delete line just after it finishes the last script process and it worked. Only prob was then the script goes back to displaying the GUI which in turn recreates the file again :D

 

So I think it's just a case of me moving where the lines are now so its created only after the button is pressed and deleted only after the last line executes.

Posted

The script is quite long, but this is the part from the teachers tab that I've just tested and works fine.

 

I would offer this up for others to use, but obviously everyones network naming convention and stuff is different......

 

And as you can see, I only use Exit if an error occurs and i want it to close. Once it completes successfully it goes back to the start of the script in case I need to add another:

 

; STAFF
   If $msg = $button_st Then
	FileInstall( "c:\pstools\psexec.exe", "",)
       $initial_st  = GUICtrlRead($initial_st)
       $surname_st  = GUICtrlRead($surname_st)
	ProgressOn ( "", "Adding User to Domain...", "Please wait...", "300", "300", 16)
			
	$valst_1 = RunWait(@ComSpec & " /c " & "net user " & $initial_st & $surname_st & " p /ADD /DOMAIN /HOMEDIR:\\server\" & $initial_st & $surname_st & " /COMMENT:""Staff User - " & $initial_st & " " & $surname_st & """ /SCRIPTPATH:logon-st.bat", "", @SW_HIDE)
	If $valst_1 <> 0 Then
		MsgBox(0, "ERROR", "Error creating user.  Please check the username doesn't already exist")
		Exit
	EndIf
	
	ProgressSet( 15 )
	
	$valst_2 = RunWait(@ComSpec & " /c " & "psexec \\server cmd.exe /c mkdir ""c:\Users\Staff\Teacher Home\" & $initial_st & $surname_st & """", "", @SW_HIDE)
	If $valst_2 <> 0 Then
		MsgBox(0, "ERROR", "Error creating users home folder.  Please check users home folder doesn't already exist")
		Exit
	EndIf
	
	ProgressSet( 30 )
	
	$valst_3 = RunWait(@ComSpec & " /c " & "net group staff " & $initial_st & $surname_st & " /domain /add", "", @SW_HIDE)
	If $valst_3 <> 0 Then
		MsgBox(0, "ERROR", "Error adding user to group 'Staff'.  Please check that group '2006' exists")
		Exit
	EndIf
	
	ProgressSet( 45 )
	
	$valst_4 = RunWait(@ComSpec & " /c " & "xcacls ""\\server\Staff\Teacher Home\" & $initial_st & $surname_st & """ /g administrators:f;f /y", "", @SW_HIDE)
	If $valst_4 <> 0 Then
		MsgBox(0, "ERROR", "Error setting permissions on users home area -1-.  Please check permissions on the server")
		Exit
	EndIf
	
	ProgressSet( 70 )
	
	$valst_5 = RunWait(@ComSpec & " /c " & "xcacls ""\\server\Staff\Teacher Home\" & $initial_st & $surname_st & """ /g " & $initial_st & $surname_st & ":rcxd;rcxd /e", "", @SW_HIDE)
	If $valst_5 <> 0 Then
		MsgBox(0, "ERROR", "Error setting permissions on users home area -2-.  Please check permissions on the server")
		Exit
	EndIf
	
	ProgressSet( 90 )
	
	$valst_6 = RunWait(@ComSpec & " /c " & "psexec \\server net share " & $initial_st & $surname_st & "=""c:\Users\Staff\Teacher Home\" & $initial_st & $surname_st & """ /grant:everyone,full /UNLIMITED", "", @SW_HIDE)
	If $valst_6 <> 0 Then
		MsgBox(0, "ERROR", "Error sharing users home area.  Please check the share on the server")
		Exit
	EndIf
	
	ProgressSet( 100 )
	ProgressOff()
		
	FileDelete( @WorkingDir & "\psexec.exe")
	MsgBox(0, "", "User added successfully")

Posted

The only things I can't do are:

 

make 'user must change password on next logon' tickbox enabled

change profile from local path to h:\

move user from 'users' OU to a specific one for the yeargroup.

 

I know these can be done in VB, but when I tried a VB 2 AU3 converter it didn't work properly

Posted

I have just recently started learning VB6 and have found it pretty powerful in some toys I have made for active directory. How come you chose AutoIT over VB?

 

fooby

Posted

fooby:

 

a week or so ago i asked for some help on creating a GUI to add users as we currently use a batch file.

somebody suggested autoit for doing it so i gave it a look and it's been useful so i carried on with it.

i didn't really choose it over VB as i had no experience with either, it was just suggested to me and i kept with it.

 

AutoIT is still powerful in its own right, and until the time comes that I reach its limits (doubtful :p ) I'll stick with it

 

:)

Posted

Cool :) Thanks - I have used autoIT a little bit, but found making a GUI app in VB a lot quicker. I have built a new active directory toy recently and it works well :)

 

I think with autoit if it doesnt do it there is some extension that adds the bits you need :D

 

fooby

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



×
×
  • Create New...