Jump to content

Troubleshooter5000

Members
  • Posts

    2
  • Joined

  • Last visited

Troubleshooter5000's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. I want to run an if statement based on the first 2 characters of the computer name and nothing else. The kicker is that the first 2 characters could exist elsewhere in the computer name. That presents a problem when I want to generalize this script and not worry about the entire computer name. For example, I want my if statement to function something like this. If computer name starts with “AB”, then do Thing1. ElseIf computer name starts with “CD”, then do Thing2. ElseIf computer name starts with “EF”, then do Thing3. EndIf. I already have a script to perform this task but it only looks for if the string contains the characters, not starts with. Here’s the actual code: If StringInStr ( @computername , "AB" ) Then RunWait ( Thing1 ) ElseIf StringInStr ( @computername , "CD" ) Then RunWait ( Thing2 ) ElseIf StringInStr ( @computername , "EF" ) Then RunWait ( Thing3 ) EndIf This presents a problem when the list of computers I run this on looks like this: ABAB1234 CDAB1234 EFCD1234 How can I write a script that looks for only the first 2 characters of the computer name? Should I just break down and use AutoIt to run a batch file instead?
  2. I have a line that creates a registry key with a value name that’s a file path. It generates the file path with @ScriptDir in the script since this script is meant to work from any file path. RegWrite ( "HKLM\My\Registry\Key" , @ScriptDir & "\file\path.exe" , "REG_SZ" , "My Data Value" ) So, the value name will turn from @ScriptDir & "\file\path.exe" into “C:\Unknown\Path\To\file\path.exe.” This script is being handled by an automated system and the value of @ScriptDir will change at the whim of this system. I’ll only know the beginning part of the file path for this registry value. I tried this line to delete the registry entry but it didn’t work. RegDelete ( "HKLM\My\Registry\Key" , @ScriptDir & "\file\path.exe" ) I’m new to AutoIt. I’m hoping there is way to find the registry key I created and delete it. There’s multiple registry entries at this HKLM path so I don’t want to just delete that entire key. I only want to delete my registry entry. Is there a way to maybe use RegRead or wildcards to find my registry entry and delete or something?
×
×
  • Create New...