
JBeardNC
Active Members-
Posts
27 -
Joined
-
Last visited
Everything posted by JBeardNC
-
I'm having a heck of a time trying to figure out how to call/invoke a WMI method through Autoit. I have a Powershell script that checks if a reboot is required using multiple checks including a WMI method related to ConfigMgr/SCCM but I want to do this in Autoit because I have a script that does other things and prompts the user to reboot if needed. I've given up on trying to make Autoit run the Powershell script and capture the true/false return value so since I know how to do everything the Powershell script does in Autoit, minus this WMI method call, I figured I'd take a stab at doing all of it in Autoit. The WMI method involved is called DetermineIfRebootPending in the root\ccm\ClientSDK namespace in the CCM_ClientUtilities class. I've done some searching on the forums here and saw many references to the Scriptomatic so I downloaded that and when I run it, since (I'm guessing) there are no properties in the CCM_ClientUtilities class, it doesn't show up as an available option in the class dropdown (see attached image), so it doesn't seem like Scriptomatic is going to help me here unless I'm missing something. Here is the Powershell part that I'd like to convert to Autoit. $CCMClientSDK = $null $CCMSplat = @{ NameSpace='ROOT\ccm\ClientSDK' Class='CCM_ClientUtilities' Name='DetermineIfRebootPending' ComputerName=$ComputerName ErrorAction='SilentlyContinue' } $CCMClientSDK = Invoke-WmiMethod @CCMSplat If ($CCMClientSDK.IsHardRebootPending -or $CCMClientSDK.RebootPending) { $SCCMReboot = $true } So as you can see, its invoking the DetermineIfRebootPending method and then checking the IsHardRebootPending and RebootPending properties to see if they are True or False. If either are true, it sets the $SCCMReboot to true and later on down the script, it returns that value to the pipeline after checking some other registry locations to determine if reboot is required. If anyone could help me either 1) convert the above code to Autoit or 2) figure out how to run the powershell script from within Autoit and capture the return value, I'd be forever grateful. Thanks!
- 2 replies
-
- wmi
- powershell
-
(and 3 more)
Tagged with:
-
Preventing App (IE) from opening
JBeardNC replied to JBeardNC's topic in AutoIt General Help and Support
Thanks for the idea but that won't work. It only needs to prevent it from opening for around 30-40 seconds while Flash or Java install. Plus, I don't want the user to receive any error message. If anything, I'd like for them to just see a message that another application is installing and IE will open when its complete. -
When I'm updating Flash or Java for example, I am closing IE for the user beforehand and IE must remain closed as to not interfere with the install. I'd like to see if there is a (better) way to prevent them from opening IE during the middle of the update. Currently, I launch a separate process/script that simply does a While loop and every 50 ms, it checks for IE using WinExists and if it finds it, kills the process. But what ends up happening is if it closes the process at the right moment, the user will get a message that looks like a permissions error or an error like the IE shortcut doesn't exist and prompts the user to remove the shortcut and its causing some confusion. It may be because I have the 50 ms interval too small but I wanted to reach out and see if there is a better way to block an application from opening temporarily while something finishes, in this case, block IE while Java or Flash install completes. I tried using If ProcessExists and got the same results. Here's the script I'm using. Any better ideas? I just need to block IE from opening for about 30 seconds. If it has a notification (like the toast pop-up I added), that's even better but its not required. #include <toast.au3> $sMsg = "Adobe Flash is being updated on your computer." & @CRLF & @CRLF & "Internet Explorer will open once the update is complete." sleep (2000) While ProcessExists ("AdobeFlashUpdate.exe") sleep(50) If WinExists ("Internet Explorer") Then WinClose ("Internet Explorer") OpenToast() EndIf WEnd Func OpenToast() _Toast_Set(5, 0xFFFF33, 0x000000, 0xCC0000, 0xFFFFFF, 10) $aRet = _Toast_Show(0, "Please wait...", $sMsg, 10, False) ;_Toast_Hide() EndFunc Run ("C:\Program Files (x86)\Internet Explorer\iexplore.exe") Exit
-
This is kind of an old thread and you've probably found a solution already but just in case, I thought I would let you know of the reboot utility that we're about to implement which is awesome so far. Its done by CoreTech which always has great scripts/utils for SCCM. (If you already found another solution, let me know. I'm curious what others are using for this situation) http://blog.coretech.dk/kea/configuration-manager-shutdown-utility/ It looks like it meets your needs. Its a pop-up, its got custom text, ability to add a logo, and custom postpone times. You'd just have to set up an advertisement to run after software updates. I use the following command line in our environment and its received great feedback. We used to force reboot every Sunday morning and users hated that. So this has been well-liked thus far. rebootutil.exe /t:10800 /m:480 /ebM:168 /c /r /t:10800 = 3 hour countdown /m:480 = allows user to postpone for up to 8 hours /ebM:168 = only prompt user to reboot if PC uptime is 7 or more days ago /c = disables option to abort reboot /r = makes machine reboot instead of shutdown Hope this helps!
-
Hello all. I'm looking to implement a program that'll prompt users to reboot their computers when its needed. I have found a couple of similar programs here in the forums but not exactly what I need and I'm hoping that maybe I just didn't search correctly because it seems this would be a useful script to have for us in the sysadmin world. Basically, our users never reboot their computers so what we've done until now is force all machines to reboot on Sunday morning at 2am via Microsoft SCCM. If the user hasn't saved something, they are screwed. This has worked for the most part but we do get the occasional negative feedback so I'm wanting to implement something a little more elegant and something that would put the reboot more into the users hands up to a certain point. I've got a couple of registry keys that can be checked to see if a reboot is required (below). If a reboot is required, I want to show the user a message that a reboot is needed (I was thinking about using Melba23's "toast" program) and then start a timer and every hour, prompt them again and nag them until they do. After 24 hours, if they havent rebooted, it would be a little more forceful. Maybe pop up a GUI window that is more in their face and they can't work without responding to it. In the GUI, it would give them a button to reboot now or they can postpone it for 30 minutes. After they've postponed it x number of times, that postpone option goes away and they are then forced to reboot right then. I don't expect anyone to write the script for me but maybe it someone has something they've started or they've used in the past that is somewhat similar to what I'm looking for, I'd be interested in seeing how it was done. These are the two registry items that I would check to determine if a reboot is required. If you are aware of any others, please let me know! HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations Thanks!
-
So here's the deal... we use Microsoft Office Communicator at my company (basically a corporate IM client) and there is an option to automatically save all conversations to your Outlook. However, we have a group policy that blocks that option from being checked. We're still allowed to save the conversations but we just have to do it manually by clicking File -> Save Conversation. Why we're allowed to save manually but not use the auto-save feature is beyond me... its politics... whatever. Anyway, how hard would it be to have a little application running in the background that would detect each time a Communicator chat window closes and before it closes, automatically send Ctrl + S which is the shortcut key to save the convo? The chat window always has the same window title so that wouldnt be an issue. The question is how to "catch" a window closing and perform an action before it closes?
-
Deploying Compiled Exe via SCCM
JBeardNC replied to RommelS01's topic in AutoIt General Help and Support
So the "OASIS Super-PlayMate InstallShield Wizard" never pops up? How long does the icon stay in the tray? I'm not familiar with this app but I'm assuming you've researched it and found that there is not an uninstall command line switch? Rather than simulating keystrokes, if its a true InstallShield installer, you should be able to automate the uninstall by creating a "response" file by running the .exe with a /r switch. I've never done an uninstall using a response file but that should record the choices into an .iss file which will autoamtically be created in the Windows directory of the machine you ran it from. Then in SCCM, you include the .iss file in your package source and then use the /s switch in the command line to run the uninstall without even using a script. Plus its completely silent... always a plus in my book. Heres more info on InstallShield command line arguments. Check out the uninstall section. I could be wrong but if what I said is true, its much easier than writing a script to simulate keystrokes IMO. http://kb.flexerasoftware.com/doc/Helpnet/installshield12helplib/IHelpSetup_EXECmdLine.htm -
Deploying Compiled Exe via SCCM
JBeardNC replied to RommelS01's topic in AutoIt General Help and Support
The fact that you mention you have the "Allow users to interface" option checked suggests that you're running as admin. Have you tried running as user? -
I did a search and saw a couple of posts about this but not this particular issue. Ever since I upgraded to Windows 7, if I have Windows Explorer opened and I'm browsed to the destination directory of the compiled script, and I attempt to compile or build, I get the "Error opening destination file" message. As soon as I go to the parent directory in Explorer, compiling works as it should. It appears that Windows Explorer is somehow forcing the compiled .exe to be read-only when that directory is opened. I've noticed that even if I have the compiled .exe highlighted in Windows Explorer on a completely separate machine (I write my scripts on my computer but test them on another), that this prevents me from successfully compiling the script. Yet as soon as I go to the parent directory or really any other directory but the destination, I have no issues. I'm not sure if this is a Windows 7 issue (it does not happen on XP) or if its an issue with my AutoIt installation but wanted to get some feedback from the community to see if anyone else experiences this strange behavior. Obviously, its not a show stopper, just an annoyance, but if theres an easy fix I'm overlooking, I'd love to hear it. I find myself always checking what Explorer windows I have opened now before I can compile any scripts.
-
Capture filename being opened in Excel
JBeardNC replied to JBeardNC's topic in AutoIt General Help and Support
Thats not quite working the way I need it but I think you're helping me to get on the right track. Below is the code I'm using. I commented out the temp folder modification just for testing. If I launch the script and then try and open Excel by double-clicking on an .xls file, I get an AutoIt error that says "Error: The requested action with this object has failed". However, when I already have Excel opened and then I launch the script, it'll give me the name of the file, which is great, but then when I click OK, it gives me the same error. The error states that its happening on line 9 which is the For $element In $oExcel.Application.Workbooks line. Any ideas? While 1 sleep(100) If ProcessExists ("EXCEL.EXE") Then $oExcel = ObjGet("", "Excel.Application") For $element In $oExcel.Application.Workbooks MsgBox(0,"",$element.FullName) Next $oExcel.Application.Quit ;~ ENVSET("TEMP", "C:\WINDOWS\System32\Temp") ;~ ENVSET("TMP", "C:\WINDOWS\System32\Temp") ;~ Run ("EXCEL.EXE " & $CmdLineRaw) ;~ EnvSet("TEMP", "%USERPROFILE%\APPDATA\LOCAL\TEMP") ;~ EnvSet("TMP", "%USERPROFILE%\APPDATA\LOCAL\TEMP") EndIf WEnd -
I need some help with capturing the filename that is being opened (if its even possible). Quick background, we are finding that our antivirus software is causing Excel to open very slow. The reason is when Excel is opened, there are some .TMP files that get placed in the temp folder and the antivirus is scanning these files before Excel will open resulting in a minimum 8-10 second delay of opening Excel. If we change the temp folder location to some other folder that antivirus doesnt scan, then Excel opens in a flash. So we have a situation where when Excel is opened, either by launching the program manually or by double clicking on an .xls file, we need to change the file location for temporary files to a folder that is not being scanned by antivirus and then allow Excel to open. After Excel opens, we then need to change the temp file location back to normal (due to security risks, we don't want to permanently keep the temporary file location assigned to a folder that isnt being scanned). So what I've done is created a script that will sit in the background on the machine and monitor for the EXCEL.EXE executable. When it detects its been opened, it'll close it and set the TEMP environment variable to C:\temp. Then it will open Excel and then change the TEMP environment variable back to its original location (%userprofile%\AppData\Local\Temp). This all happens very quickly and you can't even tell that something is happening behind the scenes. Only problem is, it works if you open Excel by a shortcut or by launching EXCEL.EXE by itself but when you launch Excel by double clicking on an .xls file, it opens Excel but the .xls file doesnt get opened because the filename argument doesn't get passed on to EXCEL.EXE in the script. This is where I need help. Is there a way in my script to determine which .xls file is being opened when a user double-clicks on it so that I can pass that along to EXCEL.EXE? Heres the code I'm using. Very simple... just need to figure out how to pass along the original argument so that Excel opens the file that the user chose. Any ideas? The more I think about it, I am not sure its possible to capture the filename so if you can think of a better way to accomplish this, I'm all ears. While 1 sleep(100) If ProcessExists ("EXCEL.EXE") Then ProcessClose ("EXCEL.EXE") ENVSET("TEMP", "C:\Temp") Run ("EXCEL.EXE " & <filename argument would be here>) EnvSet("TEMP", "%USERPROFILE%\APPDATA\LOCAL\TEMP") EndIf WEnd
-
Nevermind... simple Google search reveals the location of cookies on Windows 7 PC's. I modified the variable and I'm good to go. Thanks!!!
-
Awesome!! That works great on an XP machine. Can't get it to work on Windows 7 though. The @UserProfileDir & '\Cookies' folder apparently does not exist or something because if I try and browse to that, I get access denied (strange). Any thoughts on how to get it to work on W7?
-
I did a search for deleting cookies and I found ways to delete ALL cookies but wondering if anyone knows of a way to delete specific cookies. I need to delete, for example, any cookies like "*.google.com" I tried using the FileListToArray function on my Cookies folder (Temporary Internet Files folder on Windows 7) and it doesnt seem to work like it does on any other folder. Any thoughts?
-
We are implementing Microsoft AppLocker in our corp and for those who aren't familiar with it, you can use AppLocker to allow or deny certain applications to run on the users machine. I would like to "whitelist" all of the scripts/apps I create in AutoIt by adding a specific publisher to all of my apps and then I can go into AppLocker and tell it that anything with "Custom Inc" (for example) as the publisher is allowed to be executed. Does anyone know if its possible to add any specific properties to AutoIt scripts/apps such as publisher? I didnt see that option when compiling. Thanks!
-
Execute command and then pause in shell window
JBeardNC replied to JBeardNC's topic in AutoIt General Help and Support
I do not want to use a batch file though. Any way around that? -
I did exactly what you suggested about a year ago and created a script that moves the cursor back and forth a couple of pixels every few minutes. May not be the most well written script you've ever seen but it works great for me. Even puts a little tray icon for you to pause it when needed. I run it all day. TraySetIcon ("Shell32.dll", 28) TraySetToolTip ("Screen Saver Terminator" & @CRLF & "Moves mouse every couple of minutes to prevent machine from going idle.") While 1 $x = MouseGetPos (0) sleep (120000) $Current = MouseGetPos (0) If $Current = $x Then $y = MouseGetPos (1) MouseMove ($Current + 20, $y, 5) MouseMove ($x, $y, 5) EndIf WEnd
-
Whats the trick to do something like this in AutoIt without using a batch file? I would like to run a command line and then pause so that I (or another user) can see the result of the previous command and then the "pause" would allow me to press any key to close the window. Right now, if I run a command, the shell window closes before I get a chance to see whether the command was successful or not. For example, if I wanted to run the command "net use Z: \\server\share" and then "pause", is it possible to do that using either ShellExecute or just the simple Run (@ComSpec...)? I know with a batch file, I could do it by doing something like this: *test.bat* net use Z: \\server\share pause exit I am wondering if its possible to do this all in one line though so that I do not have to use a batch file and can use the built in AutoIt Run or ShellExecute functions to accomplish this. Hope I'm explaining myself correctly. Thanks for your feedback.
-
Just curious, what was the fix?
-
I have a GUI that I don't want my users to ignore. I've already got it set so that they can't minimize it or close it without choosing an option but I'm afraid that they'll move it entirely off the screen. How can I make it so that if its moved, it automatically re-centers itself? AdvaTHANKSnce
-
I'm writing an application that prompts the user to install an application and it gives the user the option of postponing the installation for one hour. Until now, I've just used the sleep(3600000) function whenever the user presses the postpone button. However, I'm looking to add additional functionality where say a user hit the postpone button but 15 minutes goes by and he/she thinks that now would be a good time to run the installation. Rather than forcing them to wait the entire hour, I want to give them the ability to run it manually. I was thinking a tray icon and when the icon is clicked, they can choose "Run now" or something to that effect. If I do this, I wouldn't be able to use the sleep function because if the application is sleeping, it wont be accepting input from the tray icon (am I wrong on that?). So I was thinking of creating my own custom sleep function that would basically countdown 60 minutes but still have the ability to receive input from the tray icon. Is there a built in function to do that or would I need to create my own? Does anyone have some sample code of a way to do this?
-
Hey everyone. I'm a Microsoft SCCM administrator and most of my AutoIt scripts are just "wrappers" to run command lines that install different programs on to users computers. I've been searching the forum because I've been trying to find some form of a installer wizard that I can use to provide a graphical interface to users with a progress bar when installing some of the scripts I've written. It doesnt seem like AutoIt is the right tool to create these install wrappers that I'm looking for. I saw a couple of examples that others have written but nothing that looks as pretty as one that is created with Wise, Installshield, or Inno Setup. This may be like comparing apples and oranges because I know AutoIt is not an installation wizard creator. I'm just looking for some guidance on what other people use to create an installation wrapper. I have Wise Package Studio and I've tried writing WiseScripts and I've also downloaded Inno Setup but I just really like the coding syntax and many other options that AutoIt provides and I'd like to stick with that if I could. I've been using AutoIt for about 2 1/2 years now and I consider myself a pretty good coder when it comes to silent installs but there are times when I need to write scripts that have a GUI/Progress bar and I was hoping that AutoIt had that capability. However, it doesnt seem that it does. I was wondering if anybody could recommend a good tool to use that would give me the ability to create an install wrapper. If others have had good experiences using Wise or Inno or Installshield or any others that I dont know about, I'd like to hear your opinions. Maybe you've used another tool in conjunction with AutoIt and had success. I want to point out that I'm not trying to steer anyone away from using AutoIt and I hope my post doesnt offend the programmers or the AutoIt fans. In fact, I'm a huge fan. I use AutoIt for all of my scripts and I love its features, but it appears that its just this one feature away from being the perfect programmers tool.
-
Thanks Authenticity! Thats exactly what I was looking for! Appreciate the help.
-
Hey everyone. We are implementing cwRsync in our environment and for those who are familiar with it, you know it is basically a command line utility that is run from a .bat or .cmd file. Below is the .bat file that I've written and it works perfectly to backup my files to a remote computer called BACKUP-PC. However, my management does not like how anyone could open the file in Notepad and view the password so I told them that I thought I could write it in AutoIt and then compile it into .exe format so that the password would not be in plain text for everyone to see. I'm trying to figure out the best way to do this. Using the example below, is it possible to make this into AutoIt? I've used @comspec before but what about the two SET commands at the top. How do I set those two variables since they are variables that are for the rsync executable, not variables for the script? For example, in AutoIt, if I put Run(@comspec & " /c " & "SET CYGWIN=nontsec") on one line and then Run(@comspec & " /c " & "SET RSYNC_PASSWORD=pa55w0rd") on the next line, doesnt that run those two lines separately and once they run, the variables are erased from memory? Maybe I'm wrong, I dont know much about the SET command. If anyone has any ideas, please let me know. Thanks! .BAT file looks like this... SET CYGWIN=nontsec SET RSYNC_PASSWORD=pa55w0rd cd "%ProgramFiles%/cwRsync/bin/" echo "Start Time is " %TIME% rsync --stats -vru --log-file=/cygdrive/c/rsync.log --chmod u+rwx --super /cygdrive/c/Files* %USERNAME%@BACKUP-PC::%USERNAME%/Files echo "Finish Time is " %TIME% pause
-
I'd just like to apologize. I'm SO sorry for wasting Inverted's precious time asking a question. It probably took him more time to write a reply than it did to read through the post. I'm just glad that he set me straight. I'll be sure to read through the help file 15 times before making a post again. How dare I post a question on a "General Help and Support" forum. I should be waterboarded for that. Actually, I had already tried DirRemove ( $VMFolder, 1 ) before I wrote the original post because I did and always do check the help file first. What ended up fixing it was, instead of using the variable in the DirRemove function, I wrote out the path and did DirRemove ( "C:\VM", 1 ) and that seemed to work. Not sure why it didnt work with the variable in there. I didn't mention that in my follow up post because other than letting everyone know that this was resolved, I didn't think it was really wasnt worth mentioning. Thanks everyone for your help. And again, I'm very sorry, Inverted. I hope, for your co-workers sake, that you are in a better mood by lunch time. It must suck working with a jerk all day.