olivertwistcoder Posted August 8, 2008 Share Posted August 8, 2008 As always, i wrote this program because i was bored to authenticate to each server each i need to reach it to work. So, when i open my session on windows, it launch this program (task scheduler) to authenticate on a list of servers (with a same password) in UNC mode. A ini file is build at the first time, the password is crypted in file, and a file contain the list of servers. I've already posted something like this but now it's all in English. To verify it works well, don't sign in your servers, then launch this prog, and then just navigate on servers directly. expandcollapse popup#include <file.au3> #NoTrayIcon If FileExists("cfgconst.ini") Then ;on fait rien Else MsgBox(64,"Reference File Creation", "Beware !" & @CRLF & @CRLF & "You're going to create the configuration file" & @CRLF & @CRLF & "In case of problem, you can modify cfgconst.ini after the creation") $usercfg=InputBox("UserName/admin","Please enter a username authorized on servers : ","Administrator") IniWrite("cfgconst.ini","User","Key",$usercfg) $nbservers=InputBox("Servers number","Please indicate the servers number : " & @CRLF & @CRLF & "(Beware ! same user, same password)","") IniWrite("cfgconst.ini","NbServers","Key",$nbservers) $sharecfg=InputBox("Share Name","Please enter the default share name : ","c$") IniWrite("cfgconst.ini","Share","Key",$sharecfg) EndIf $user = IniRead("cfgconst.ini", "User", "key", "NotFound") $nb = IniRead("cfgconst.ini", "NbServers", "key", "NotFound") If FileExists("serverslist.ini") Then ;on fait rien Else MsgBox(64,"Creation of servers list", "Your'e going to create the servers list to access to" & @CRLF & @CRLF & "In case of problem, you can modify serverlist.ini after the creation") MsgBox(48,"Beware", " - The server name must be resolved in DNS" & @CRLF & @CRLF & " - You can put an IP address" & @CRLF & @CRLF & " - Do not put any \ or \\ before or after the name or IP address " & @CRLF & @CRLF & " example : server911 " & @CRLF) For $d=1 to $nb $servername=InputBox("Server Name","Please enter the server name " & $d & " on " & $nb,"") IniWrite("serverslist.ini","Server" & $d,"Key", "\\" & $servername & "\" & @CRLF) Next EndIf $share = IniRead("cfgconst.ini", "Share", "key", "NotFound") $user = IniRead("cfgconst.ini", "User", "key", "NotFound") $nb = IniRead("cfgconst.ini", "NbServers", "key", "NotFound") $replog = IniRead("cfgconst.ini", "Replogs", "key", "NotFound") If FileExists("cryptage.ini") Then $PASSKEY = "PASSWORD" $M_PASSWORD =IniRead("cryptage.ini","program","password","") $M_PASSWORD = Crypt($PASSKEY,Hex2Str($M_PASSWORD)) Else MsgBox(48,"Password Warning", "Beware !" & @CRLF & @CRLF & "You're going to pu the password of user : " & $user) $PASSKEY = "PASSWORD" $PASSWORD=InputBox("Password of " & $user,"Enter the password to register : " & @CRLF & @CRLF & "(You must confirm it once more but not by the future)","","*") $TEMP = Str2Hex(Crypt($PASSKEY,$PASSWORD)) IniWrite("cryptage.ini","program","password",$TEMP) $PASSWORD=InputBox("Password","Enter password to verify : ","","*") $M_PASSWORD =IniRead("cryptage.ini","program","password","") $M_PASSWORD = Crypt($PASSKEY,Hex2Str($M_PASSWORD)) If $M_PASSWORD == $PASSWORD Then MsgBox(0,'Ok', "Passwords are the same.") Else MsgBox(16,'Houlala !!!', "Password are different !!!") FileDelete("cryptage.ini") Exit EndIf EndIf Func Crypt($PASS, $STRG) $A = 1 $N_STRG = "" For $I = 1 To StringLen($STRG) $B = Asc(StringMid($PASS, $A, 1)) $A = $A + 1 If $A > StringLen($PASS) Then $A = 1 $N_STRG = $N_STRG & Chr(BitXOR(Asc(StringMid($STRG, $I, 1)),$B)) Next Return $N_STRG EndFunc Func Str2Hex($STRG) $H = "" For $I = 1 To StringLen($STRG) $H = $H & String(Hex(Asc(StringMid($STRG, $I, 1)),2)) Next Return $H EndFunc Func Hex2Str($H) $STRG = "" For $I = 1 To StringLen($H) Step 2 $STRG = $STRG & Chr(Dec(StringMid($H, $I, 2))) Next Return $STRG EndFunc main() Func main() Local $cmd Local $result Local $msg For $i=1 to $nb Local $serv $serv = IniRead("serverslist.ini", "Server" & $i, "key", "NotFound") Run('net use ' & $serv & $share & ' /USER:' & $user & " " & $M_PASSWORD, @tempDir, @SW_HIDE) $result = RunWait(@ComSpec & " /c " & $cmd, "") If $result <> 0 Then ConsoleWriteError("Error : RunWait() returned an error code : " & $result & @CRLF) EndIf ConsoleWrite($cmd & @CRLF) Next EndFunc 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