Jump to content

kgreer

Active Members
  • Posts

    31
  • Joined

  • Last visited

kgreer's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. @ BrewManNH I'm writing a printer management utility and I'm using the Windows included vbs scripts and command line switches to manage the printers. https://technet.microsoft.com/en-us/library/cc725868.aspx Thanks for the autoit example. I want to learn more about WMI and objget(). I am actually using many functions from the vbs print management scripts, but it would be nice to eventually only perform the tasks from within autoit. @ boththose and Zedna, those work perfectly! Thank you for the help. your one liner msgbox(0 , '' , StringRegExp($sStr , "The default printer is (.*)" , 3)[0]) beats my attempt using $output = StringSplit($sOutput, "default printer is", 1) $output = StringSplit($output[2], "\", 1) msgbox(0,"",$output[UBound($output) - 1])
  2. I am trying to get the default printer name from the below command line output. I can capture the outpupt by using StdoutRead(), but I just want the value after "The default printer is ". I can use stringsplit($sOutput,"default printer is",1) and get the data from the returned array which works fine, but I want to use StringRegExp(), and I'm having trouble figuring out the logic and I'm hoping to hear from someone with a better understanding on the logic to use with StringRegExp(). So, using StringRegExp(), how can I just get the value ServerPrinter? I thought something like StringRegExp($sOutput,"(?:The default printer is)(*)",1) but this does not work and just returns 0 Microsoft ® Windows Script Host Version 5.8 Copyright © Microsoft Corporation. All rights reserved. The default printer is ServerPrinter
  3. This might be a best practices question. It's embarrassing publishing a script for the users in my organization and I have a spelling typo in a message box. I could copy my msgbox string and paste into Word to make sure I don't have any typos, but I think that might not be the most efficient solution. I was hoping for a SciTE plugin that I can run to check comments and strings, but I did not see any such plugin. I’m curious to know how others are spellchecking their strings and comments.
  4. Yes, I have rights. I am a local administrator on the computer and I can manually perform the tasks.
  5. I am writing a script to reset Local Group Policy settings which will first backup related registry keys and folders before removing them. It will end with running gpupdate /force. My issue is I am not able to copy the two below folders. I have tried dircopy() and runwait() with robocopy. I am running windows 8.1 but mainly this script will run on Windows 7 computers. C:\Windows\System32\GroupPolicy C:\Windows\System32\GroupPolicyUsers If I manually run the below commands the copy works, but I can't get the command to work within the script: robocopy.exe C:\Windows\System32\GroupPolicy C:UsersusernameDesktopResetGroupPolicyGroupPolicy /e robocopy.exe C:\Windows\System32\GroupPolicyUsers C:UsersusernameDesktopResetGroupPolicyGroupPolicyUsers /e Does anyone have any ideas how I can get the above commands to work whether it's with robocopy or dircopy(). The method does not matter, I just need some function to work. Thank you for assisting! #RequireAdmin #include <array.au3> Dim $LogDirectory = @DesktopDir & "\ResetGroupPolicy" Dim $arrKeysToDelete[6] = ["HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft", _ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy", _ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies", _ "HKEY_CURRENT_USER\Software\Policies\Microsoft", _ "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy", _ "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies"] DirCreate($LogDirectory) For $i = 0 To UBound($arrKeysToDelete) - 1 ShellExecuteWait("regedit.exe", "/e " & $i + 1 & ".reg """ & $arrKeysToDelete[$i] & """", @DesktopDir & "\ResetGroupPolicy\") Next DirCreate($LogDirectory & '\GroupPolicy') RunWait(@ComSpec & ' /c robocopy.exe ' & 'C:\Windows\System32\GroupPolicy ' & $LogDirectory & '\GroupPolicy /e /log+:c:\test.log') DirCreate($LogDirectory & '\GroupPolicyUsers') RunWait(@ComSpec & ' /c robocopy.exe ' & 'C:\Windows\System32\GroupPolicyUsers ' & $LogDirectory & '\GroupPolicyUsers /e /log+:c:\test.log') ;Delete Registry keys ;Delete Folders ;Run gpudate /force Here are the the errors i get in the robocopy log file. ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ------------------------------------------------------------------------------- Started : Friday, September 19, 2014 12:19:15 PM Source : C:\Windows\System32\GroupPolicy\ Dest : C:\Users\kgreer\Desktop\ResetGroupPolicy\GroupPolicy\ Files : *.* Options : *.* /S /E /DCOPY:DA /COPY:DAT /R:1000000 /W:30 ------------------------------------------------------------------------------ 2014/09/19 12:19:15 ERROR 2 (0x00000002) Accessing Source Directory C:\Windows\System32\GroupPolicy\ The system cannot find the file specified. ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ------------------------------------------------------------------------------- Started : Friday, September 19, 2014 12:19:15 PM Source : C:\Windows\System32\GroupPolicyUsers\ Dest : C:\Users\kgreer\Desktop\ResetGroupPolicy\GroupPolicyUsers\ Files : *.* Options : *.* /S /E /DCOPY:DA /COPY:DAT /R:1000000 /W:30 ------------------------------------------------------------------------------ 2014/09/19 12:19:15 ERROR 2 (0x00000002) Accessing Source Directory C:\Windows\System32\GroupPolicyUsers\ The system cannot find the file specified.
  6. thanks MikahS, I like the use of the AdlibRegister() function. Does omitting the sleep() function cause the script to use more CPU time?
  7. A few people have expressed some concerns with Outlook's ability to remind them of meetings. the reminder window will be active but minimized and the users would miss appointments. I figured I could use Autoit to solve this problem by making the Outlook reminder window more agressive with reminders. Here is what I came up with, and I would like some feedback or suggestions to make this better or more efficiant. One problem I had was with the title paramater as partial text was not working, however it seems to work with just finidng text from within the window. This will work for Outlook 2013, but Outlook 2010 and 2007 have slightly different text within the window body, "Click Snooze to be reminded again in". I do not run a check on which version of Outlook is installed or if multiple versions are installed. That may be something to add later on. #NoTrayIcon $winTitle = "" $winText = "&Click Snooze to be reminded in:" While 1 If WinExists($winTitle, $winText) Then WinSetState($winTitle, $winText, @SW_SHOW) WinSetState($winTitle, $winText, @SW_RESTORE) WinSetOnTop($winTitle, $winText, 1) WinFlash($winTitle, $winText, 10, 500) EndIf Sleep(20000) WEnd
  8. I have 4 scripts. Installation script, scipt that runs at startup or computer unlock, and two others. The installer creates a key in the registry and assignes a value poinitng to the installation source. RegWrite($RegistryKey, "InstallationSource", "REG_SZ", $InstallationSource) It also imports a xml schedule task to run officecheck.exe (just the name I gave my script) at each startup and unlock, then runs officecheck so it populates other vaues in the $RegistryKey location. a few examples below. RegWrite($RegistryKey, "External IP", "REG_SZ", $PublicIP) RegWrite($RegistryKey, "Office", "REG_SZ", $arrReadOfficeList[$i]) RegWrite($RegistryKey, "IP 1", "REG_SZ", @IPAddress1) Dim $InstallationSource = RegRead($RegistryKey, "InstallationSource") ;###Make sure this key is created by the installer When another user logs in, the key created by the installer is no longer available. I have error handling so the user gets notification that the key is missing and it attempts to re-install which works and all, but I dont like that method. I rather the values to be availabe for all users and to not have potential different values for multiple users.
  9. Hi, I wrote a series of scripts that write and read values to the registry. This seems good until another user logs onto the computer and the values are no longer accesible since they are stored in the HKCU hive. I didn't want to create the key in HKLM because I dont want to add #requireadmin. I managed to write a work around, but its more of a bandaid. I'm considering replacing all of the reg write and reads with INI write/read functions and storing the INI somewhere in C:UsersPublic. The registry writes and reads occur at every login and computer unlock (called from a scheduled task) and I wasn't sure if wrinting to a INI file that frequently would cause any problems. Basically, I'm asking what are best practices when storing varialbes for scripts that need to read /write values as well as being accessible for all users without full administrator rights.
  10. That's why I was thinking of comparing each @IPAddress macro. I know I have a Virtual Box network connection that is the same no matter where I go. My thought was to compare all 4 macros and if any of them are differnet, then I'm going to assume that the computer has probably moved to another network. Another question. Why are there 4 @IPAddress macros? Where is Autoit getting them from?
  11. Hi AutID, I am refering to comparing the IP address obtained by using @IPAddress1 JohnOne, That sounds like a good idea. I'm going to consider that.
  12. I have a drive mapping script that needs to know which office the computer is in or if the computer is out of the office for laptop users. Each office has a static Public IP address which I obtain by launching a separate script at startup that runs _GetIP(). I save the public IP address to the registry so I only have to run _GetIP() once per startup because I have noticed it sometimes fails and I have to run it until I get an IP address. If I run this within the drive mapping script, it may halt the script for several seconds (about 20 at the most I have noticed) and the user will think it is not running. That is why I have a separate script for determining the external IP address. $PublicIP = _GetIP() While $PublicIP = -1 Sleep(1000) $attempt = $attempt + 1 $PublicIP = _GetIP() If $attempt = 30 Then ExitLoop EndIf WEnd My drive mapping script will check the registry to determine what office it is in or if it is out of the office and map drives accordingly. However my concern is if a laptop starts up while in the office and the laptop is put to sleep and woken back up while out of the office, the drive mapping script will think it is still in the office. I was thinking about using the startup script to record @IPAddress1 to the registry and my drive mapping script will compare the first couple octets of @IPAddress1 with what was recorded. If it is different, then it will know the network has changed and will run the startup script to determine which office it is in or if it is out of the office. I also am not sure if using only @IPAddress1 is good enough or if I should record each @IPAddress macro since some computers may have multiple adapters. Would comparing the IP address with the recorded IP address solve my problem or is there a better way to go about doing this. Thank you in advance for any input!
  13. If $extension = "msi" Then Run("msiexec /i " & '"' & $scriptDir & "Software" & $fileName & '" ' & $switch) ; For MSI type installers Else RunWait('"' & $scriptDir & "Software" & $fileName & '"' & " " & $switch) ; For EXE installers EndIf is there a reason that run() is used for MSI installs vs using runwait?
  14. OK, that makes more sense so this would do the same thing? GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 375) I was also searching for a list of available messages for at least the listview and hopefully the below link has all the answers I need. http://msdn.microsoft.com/en-us/library/windows/desktop/bb761163%28v=vs.85%29.aspx
  15. Thanks marshal, I see. What is msg parameter doing. I cant find a descripton on the code 0x101E.
×
×
  • Create New...