Jump to content

freddykid

Members
  • Posts

    8
  • Joined

  • Last visited

About freddykid

  • Birthday 06/29/1981

Profile Information

  • Location
    MA

freddykid's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thanks for the reply, Yeah sorry I tried to keep this as short as possible in the area I had a problem with. But once the "net localgroup" @error = 0 I exit the loop and force logoff. if @error <> 0 then MsgBox(0, "Attemp to add", "Action Failed ", 10) Exit ElseIf @error = 0 then ExitLoop Wend MsgBox (0, "", "Please logoff and Re-run the ASM script again...Logging off in 15 seconds.",15); If the user did not have Admin Rights then the script forces a logoff. RunWait ("Shutdown.exe -l -f",@SystemDir, @SW_SHOW) This is nested in another loop which checks prior if the user is an admin.if they are it skips this whole part.
  2. The issue was a syntax issue that I finally worked out. I removed @comspec and then specified the working Dir... even though it should have defaulted there. Old not working $result4 = runaswait ("admin1",@ComputerName, "Password1",1, @ComSpec & 'net localgroup administrators microsoft\'&$sInputBoxAnswer &' /ADD', @SW_SHOW) Working syntax $result4 = RunAsWait ('admin1',@ComputerName, 'Password1','', 'NET LOCALGROUP administrators microsoft\'&$sInputBoxAnswer & ' /add', @SystemDir); insert the name typed by the Technician
  3. I have a Annual sales meeting coming up and I have been working on an automated system maintenance, clean up and install some reporting software and such. We are servicing three different domain's users and each domain has a different local admin account. So for the maintenance to function correctly the user will need Admin rights. So I have a username prompt and the use the @logondomain macro to get which domain they belong too. I am using the runaswait function to run a net command to add them as an admin. My problem may be syntax or the way I am formating the strings, I honestly spent 5 hours just on this part of the script and am stuck. Everything after this portion runs fine once the user has admin rights. I am hoping someone can help cure my insanity or show me a better way to do this. While 1 If Not IsDeclared("sInputBoxAnswer") Then Dim $sInputBoxAnswer ; Prompt for Technician $sInputBoxAnswer = InputBox("Domain Username","Enter your PC login account (ex. Tsmith): ","" & @UserName," ","300","150","555","555");Default autofill with current logon name. Select Case @Error = 0 ;OK and the string returned is valid If $sInputBoxAnswer <> "" Then ExitLoop Case @Error = 1 ;Cancel button was pushed Exit Case @Error = 3 ;Timeout Exit EndSelect WEnd While not IsAdmin() $domain1 = String("Microsoft") $domain2 = string("Contoso") $domain3 = string("fabricam") $domain = String(@LogonDomain) ;$compname = String(@Computername) MsgBox(0, "Domain","" &$domain & @LF & $domain1 &@lf & $domain2 &@lf & $domain3, 15); show me how they are populated for debugging $result1 = StringCompare ($domain, $domain1 ) $result2 = StringCompare ($domain, $domain2 ) $result3 = StringCompare ($domain, $domain3) Select ;This will Select will add user to the local admin group based on their domain using thier local Admin account. Case $result1 = 0 ;String is the same $result4 = runaswait ("admin1",@ComputerName, "Password1",1, @ComSpec & 'net localgroup administrators microsoft\'&$sInputBoxAnswer &' /ADD', @SW_SHOW); insert the name typed by the Technician if @error <> 0 then MsgBox(0, "Attemp to add", "Action Failed " & $result4, 10) FileWrite(@ComputerName&".txt", @CRLF & "really you suck at scripting "&$sInputBoxAnswer &@CRlf) Exit EndIf Case $result2 = 0 runaswait ("admin2", @ComputerName, "Password2",@ComSpec & 'NET LOCALGROUP administrators contoso\' & $sInputBoxAnswer & ' /ADD', @SystemDir, @SW_HIDE);insert the name typed by the Technician Case $result3 = 0 RunAsWait ("admin3", @ComputerName, "Password3",@ComSpec & 'NET LOCALGROUP administrators fabricam\' & $sInputBoxAnswer & ' /ADD', @SystemDir, @SW_HIDE);insert the name typed by the Technician EndSelect WEnd
  4. So I have a question really. I have a little 50 some odd line script that the only function is to allow limited user to change timezone. But for it to run I need to use the local admin with runas. I was reading through the help file and it says you should not store passwords in the script itself even with Obfuscator. So I am look for suggestions on ways that i can keep the file secure. this is a sample of my script, i used an example to display time after the change, this is really a 2 or 3 line action, as it stands. If there ways that i can lock-it down any help would be great. ; Launch Time and Date control Panel with admin RunAsWait("Admin",@ComputerName,"Password",0,"rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,",@SystemDir,@SW_SHOW) sleep (500) ;slight pause for change to take effect MsgBox(0, "Time", "Your Time Zone has been updated.") ;Start gui to show time change._ Main() Func _Main() Local $hGUI, $tFile, $tLocal ; Create GUI $hGUI = GUICreate("Time", 300, 100) $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 296, $WS_VSCROLL) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() ; Get system time $tSystem = _Date_Time_GetSystemTime() $tFile = _Date_Time_SystemTimeToFileTime(DllStructGetPtr($tSystem)) ; -------------------------------------- $tLocal = _Date_Time_FileTimeToLocalFileTime(DllStructGetPtr($tFile)) MemoWrite("The time is now : " & _Date_Time_FileTimeToStr($tLocal)) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite
×
×
  • Create New...