Jump to content

cryn

Members
  • Posts

    11
  • Joined

  • Last visited

cryn's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. np i guess it's just coding preference then either way good job on the script.
  2. First thing good job. I written reg all script in vb, kix, Autoit. So am very familiar with the concept. I see 2 problems. 1. Getting Profile Directory value is ok but then you have to enumerate the files which will take longer. It's best to go enumerate the profilelist for each S-1-5-21-XXXX is a user profile within each one you will see string "ProfileImagepath" that has a value exp.("%systemdrive%\Documents and Settings\JoeSmith") then all you need to add is \ntdat.dat". There is another reason why you want to do this. That would be in #2 2. Another issue is if the hive is already loaded it will fail. It is not uncommon for having two or more hives loaded at the same time it is only because when enduser logs off it doesn't unload for some reason. So how to resolve of it is easy you need to verify first if it's loaded. if you enumerate each profilelist it has a unique S-1-5-21-XXXXX then verify under the HKEY_USERS you will find the Unique Profile ID if its there then its loaded. Then you will just need to write the keys there. If you dont find it then use the value for "profileImagePath" while adding "\ntdat.at" then write to it. If you do it this way it should run faster and wont skip any profiles. Ignore S-1-5-18,S-1-5-19, and S-1-5-20 are for your local admin accounts exp(network,system accounts)
  3. you can use the same object in autoit. $shell = ObjCreate('Shell.Application') $shell.EjectPC
  4. Try giving the working directory. Run ('\\server\folder\program.exe','\\server\folder\',@SW_SHOW)
  5. Sorry but is there reason why you prefer using a shortcut then actually putting the target information to a Run or Shellexecute function?
  6. here's another way of doing it. add this to the top of your script. Opt("ExpandEnvStrings", 1) So you can use variables in your strings Run('%systemdrive%\windows\system32\cmd.exe')
  7. Sorry just realize what i wrote wouldn't have made sense. There is a function called stdoutread() that reads the output of your Code $foo = Run($cmd,@workingdir,@SW_MAXIMIZE,2+4) This is from the Autoit Help ; Demonstrates StdoutRead() #include <Constants.au3> $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($foo) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) Wend While 1 $line = StderrRead($foo) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) Wend MsgBox(0, "Debug", "Exiting...")
  8. I think what your talking about is fast user switching which lets you have the accounts still logged in below i supplied a link to micro$osft how to disable that feature. http://support.microsoft.com/kb/279765
  9. Did you try StdoutRead()??
  10. $i = 0 do "your code here" until $i = 1
  11. Wanted to post this under "Example Scripts" forum but I did not have the permission. 2 days ago I needed to create something like pskill to kill process and all its child process. I searched thru the forums hoping someone already done this but only found left for dead post threads of the subject. So i took a stab at it and this is what I came up with. Killing Process ;_processKillTree("cmd.exe") Func _ProcessKillTree($ProcessTreeKill) local $PID If Processexists($ProcessTreeKill) Then $PID = Processexists($ProcessTreeKill) $oWmiService = ObjGet("winmgmts:\\.\root\CIMV2") ;SQL query requesting for all process that has ProcessID of executable trying to kill $ChildProc = $oWmiService.Execquery("SELECT ProcessID FROM Win32_Process WHERE ParentProcessId='" & $PID & "'") If isObj($ChildProc) then ;Suspending process in case it tries to recreate child process _SuspendExe($PID) For $Child in $ChildProc ;closing child process ProcessClose($child.ProcessID) Next processclose($PID) Endif EndIf EndFunc Here's code for the _suspendExe function used in the ProcessKillTree function. Func _SuspendExe($PID) Local $THREAD_SUSPEND_RESUME =0x0002 $oWmiService = ObjGet("winmgmts:\\.\root\CIMV2") $ThreadHandle = $oWmiService.Execquery("SELECT Handle FROM Win32_Thread WHERE ProcessHandle='" & $PID & "'") if isobj($threadHandle) then For $TID in $threadHandle ;Getting the handle of thread $hwnd = DllCall('Kernel32.dll','hwnd',"OpenThread","int",$THREAD_SUSPEND_RESUME,"int",0,'int',$TID.handle) $ret = DllCall('kernel32.dll','uint',"SuspendThread",'hwnd',$hwnd[0]) next EndIf EndFunc Here's how to resume a thread Func _ResumeExe($PID) local $THREAD_SUSPEND_RESUME =0x0002 $oWmiService = ObjGet("winmgmts:\\.\root\CIMV2") $ThreadHandle = $oWmiService.Execquery("SELECT Handle FROM Win32_Thread WHERE ProcessHandle='" & $PID & "'") if isobj($threadHandle) then For $TID in $threadHandle $hwnd = DllCall('Kernel32.dll','hwnd',"OpenThread","int",$THREAD_SUSPEND_RESUME,"int",0,'int',$TID.handle) $ret = DllCall('kernel32.dll','uint',"ResumeThread",'hwnd',$hwnd[0]) next EndIf EndFunc I've tested on xp sp2 only so am not sure if it will work with any other flavor of Micro$oft. Thanks for reading and I hope someone has a use for it. Any positive suggestions would be appreciated.
×
×
  • Create New...