Scripting Languages

28K

Solutions

21K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi,

Let say I have many files in C:\temp

How can I rename all files  by *.old with PowerShell?

Thanks
0
Hello experts,
I would like to move on ahk studio as I am not fully satisfied with sciTE4AutoHotkey.
I follow instruction and download reference zip file at:
https://github.com/maestrith/AHK-Studio/archive/master.zip
I run ahk file:
ahk-studio-master_20190924_142614.pngHowever I don't know how to:
1-Open with (by default) .ahk file with ahk studio. Where should I place the AHK-Studio-master folder?
open-with-ahk_20190924_142836.png2-I also don't see ahk studio in my programs features.
20190924_142906-programs.pngI supposed that this is due to the fact that it is not a compiled version.
3-I have also the following script which allows me to edit by default .ahk files.
https://www.experts-exchange.com/questions/29157425
It open by default .ahk file with sciTE4AutoHotkey I would review it to open with ahk studio.
;====================================
;Edit file based on extension
;====================================

#NoEnv ; avoid checking empty variables to see if they are environment variables. Potential regressions if so comment this line
#SingleInstance Force ; replace old instance immediately
SetBatchLines,-1 ; run at maximum speed

+F4::
FileSelected:=GetSelectedFile()
SplitPath,FileSelected,,,FileExt
If (FileExt="ahk")
 Run,%SciTE4exe% %FileSelected%
Else
 Run,%NPPexe% %FileSelected%
Return

GetSelectedFile(hwnd="") {
; this function by sinkfaze: 

Open in new window

0
Need to Push Power shell upgrade on Dc and domain Servers  running with win 2008,2012
what should be standard  PS version ?
What all are prerequisites before we  Plan the upgrade ?
Any risk upgrading Power shell @Win 2008 ?

Can We Push it in a way to get this updated on all servers  n domain?

Thanks
0
To Achieve it..we ..
Need to Locate  Dynamic DNS entries of servers which are alive but for which the DNS entry was not updated for 30-40+ days.
Need to Locate Static DNS entries of server which are no longer existing.

Please help if this can be automated using script or utility  and will there be any Risk /Prerequisites of backup before we enable Scavenging
0
I am looking for an 'AutoHotKey'-type program for Mac.  I have to type the same/similar sentences very frequently, and I need to find a reliable short cut.  AutoHotKey was perfect, but I have moved (back) over to Mac, so it doesn't work.  I'm hoping to find a free download, and If automator or appleScript are capable of doing this I am all ears...

Here would be an example of a desired outcome:
Press [Shift + Cmnd + Delete] and the sentence 'Thank you very much for your time today' would appear in whatever app I am working with

Thanks all!
0
In attached file, only state but not .concstate has been defined. Does concstate actually refer state ?
this.props.concstate.flights.map

Thx
FlightCards.js
0
Include a script in SCCM Task Sequence

This scenario is about deploying WIndows 10  OS using USB drive Boot.
The OS is to be deployed for different floors. The issue is joining the computer to the domain automatically with the naming convention that we have.
For Instance , if a computer is to be imaged and used in 10th Floor then the name of the Computer will be Comp10 + the last 6 of the MAC address without the dashes.
 if a computer is to be imaged and used in 20th Floor then the name of the Computer will be Comp20 + the last 6 of the MAC address without the dashes.
So probably we need a script for each task sequence for each Floor.

Any better Strategy and the right script will be very much appreciated.

Thanks
0
Hello experts,
I set up the following AutoHotkey to send clipboard on google drive and upload files.
+F9::
FilePath1:=Clipboard
FilePath2:=StrReplace(FilePath1, """")
If (Not FileExist(FilePath2))
{
	Msgbox,0x10,Error, Your clipboard which report the following value %FilePath2% doesn't exist	
	Return
}
Else
Msgbox,0x40,Success, Your clipboard which report the following value %FilePath2% exist	
WinGetActiveTitle,Title
If (InStr(Title,"Google Drive"))
{
	PostMessage,0x112,0xF030,,,%Title%
	Sleep, 100
	Send, mc 	
	Sleep, 100
	Send, {Down 2}
	Sleep, 100
	Send, {Enter}
	Sleep, 1500
	WinGetActiveTitle,Title
	If (InStr(Title,"Open"))
	{	
		Send, %FilePath2%
		Sleep, 100
		Send, {Enter}
		Return
	}
	Else
	MsgBox,0x10,Error,Unable to send path as active window doesn't contains name expected
	Return
}
Else
  MsgBox,0x10,Error,Google Drive is not the active window
Return

Open in new window


I made a test with the following cases and it works:
1-Error when clipboard doesn't contain a file which exist
2-Success when the clipboard contain a file which exist
3-Error when google drive is not the active windows

Prior to adding to my AutoHotkey file I would like to have some advice to see if the AutoHotkey should be revised in term of structure, conditions and loops.
I am aware that Send keys is not the best way however this is how I can work on google drive.

Thank you for your help.
0
Hello experts,
I would like to understand why winmaximize works in some case and not in other case.

WinMaximize is applied as followed:

^+F12::
If(WinActive("ahk_exe chrome.exe"))
{
	WinMaximize
	Return
}
Else
  MsgBox,4144,Error,Google Drive is not the active window
Return

Open in new window


However it doesn't work as followed:
^+F12::
WinGetActiveTitle,Title
If (InStr(Title,"Google Drive"))
{
	WinMaximize
	Return
}
Else
  MsgBox,4144,Error,Google Drive is not the active window
Return

Open in new window

Thank you for your help.
0
Within an ssh session on an instance, here is what I'd like to accomplish:

Steps in Script:
1.  Move a file (each file starts with "cfrtl4" - about 8 files total) from the remote systems /tmp directory to the etc/deployment-apps  
      directory as the SudoUser.
2.   Continue the same process until each "cfrtl4" file from the /tmp directory has been moved into the etc/deployment-apps
      directory.
3.   Next, I'd like to chown the /opt/splunk/etc/deployment-apps directory as SudoUser:
       e.g. sudo chown -R splunk:splunk /opt/splunk/etc/deployment-apps
4.   I need to log out of SudoUser and log back in as splunkuser so that I can reboot the instance:
      sudo su splunk
5.   Now as the splunk user, I need to navigate to:  cd /opt/splunk/bin
6.   Once in the /bin directory, I need to issue a reboot command, e.g. ./splunk restart
   
[code]

#!/bin/sh
#--- Execute the script from the /tmp directory ---
sudo mv cfrtl4_all_deployment_client/ /opt/splunk/etc/deployment-apps
sudo mv cfrtl4_all_indexer_base/ /opt/splunk/etc/deployment-apps
sudo mv " "
sudo mv " "
sudo mv " "

# --- Once all of the file shave been moved from /tmp to the /deployment-apps directory, then chown the deployment-apps    
     directory ---

sudo chown -R splunk:splunk /opt/splunk/etc/deployment-apps
# --- Exit out of sudouser ---
exit
# --- Navigate to the bin directory ---
cd /opt/splunk/bin/
# ---Issue reboot command ---
./splunk restart
0
I've got a script located at:
/Users/me/Desktop/Distributed_Lab/Scripts

I'm trying to invoke the script using:  
./myscript.sh

When the script runs it gives me this message:
Desktop/cfrtl4_all_indexer_base: No such file or directory

A portion of my script is below:
#!/bin/sh
# ----- Variables -----
SHIP="xx.xxx.xx.xxx"
# ----- Script -----

# --- Search Head ---
sudo scp -r Desktop/Distributed_Lab/Apps/cfrtl4_all_indexer_base username@$SHIP:/tmp

Open in new window


I'm initiating the script from my local system where I have administrative rights.  However, I've tried the scp command with sudo and without.  Same result.  It keeps giving me this message:

"Desktop/cfrtl4_all_indexer_base: No such file or directory"

Why is the message referring to only the Desktop/ as the path and not the entire path?  More importantly, it's not seeing the file that I need to move from my Apps directory.  I created this script to move about 10 files over from my Desktop/Distributed_Lab/Apps directory which is on my local drive, on to a remote systems /tmp directory.   Any help is greatly appreciated!
0
I have attached a PowerShell script that was written to take the 'year' ID3 tag of an mp3 file, create a corresponding folder of the decade to which it belongs (ex: 1960s, 1970s, 1980s) and then move it to that respective folder.

When I attempt to run it, it does nothing. No output, no errors. I have tried running it from PowerShell ISE, Windows PowerShell prompt, and calling it via the command line (powershell c:\scripts\mp3.ps1) all when run as administrator.

Looking in the Event Viewer, there are 8 events produced, but nothing of anything discerning to me that speaks to why it won't run. Here are the events in sequence:

Provider "Registry" is Started.

Details:
      ProviderName=Registry
      NewProviderState=Started

      SequenceNumber=1

      HostName=ConsoleHost
      HostVersion=5.1.18362.145
      HostId=61667b5b-06d4-4f03-a57d-bef692dd47c2
      HostApplication=powershell c:\scripts\mp3.ps1
      EngineVersion=
      RunspaceId=
      PipelineId=
      CommandName=
      CommandType=
      ScriptName=
      CommandPath=
      CommandLine=

Provider "Alias" is Started.

Details:
      ProviderName=Alias
      NewProviderState=Started

      SequenceNumber=3

      HostName=ConsoleHost
      HostVersion=5.1.18362.145
      HostId=61667b5b-06d4-4f03-a57d-bef692dd47c2
      HostApplication=powershell c:\scripts\mp3.ps1
      EngineVersion=
      RunspaceId=
      PipelineId=
      CommandName=
      CommandType=
      ScriptName=
      CommandPath=
      CommandLine=

Provider "Environment" is Started.

Details:
      ProviderName=Environment
      …
0
For the below code in React :

Does (city,key) is the input or output parameter for the function findAirport ?
What does "then(jsonData => {this.setState({ [key]: jsonData.Places[0].PlaceId });" mean ?
Does the code inside { } is the body of the function ?
What does .then mean ?
Can I omit 'this' for "this.findAirport" ?
Where does setState function defined ?

ThxFindFlight.js

   this.findAirport = (city, key) => {
      fetch("https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/autosuggest/v1.0/US/USD/en-US/?query="+city, {
        method: "GET",
        headers: {
          "X-Mashape-Key": process.env.REACT_APP_MASHAPE_API_KEY,
          "X-Mashape-Host": "skyscanner-skyscanner-flight-search-v1.p.rapidapi.com"
        }
      }).then(response => {
        return response.json();
      }, error =>  {
      }).then(jsonData => {
        this.setState({ [key]: jsonData.Places[0].PlaceId });
        console.log(this.state);
        if (this.state.toairport.length > 0 && this.state.fromairport.length > 0){
          this.findFlight();
        }
      })
    }

Open in new window

0
i have following commands which i run manually on a server by opening command prompt.

tabadmin stop

tabadmin clean up

tabadmin start

Is there any way i can automate this task by task scheduler .

can i save this in txt format file and save in .ps1 script but i am not sure
how to do it.
0
I need to write a script that will find all plist files in /Library/LaunchAgents/ that start with connectwisecontrol and contain onlogin in the file names then unload them.

We use ConnectWise Control for providing remote support to our users. The client is installed on the machine and runs at boot. The problem is that we have an application that is used a few times per year that conflicts with ConnectWise Control. Our solution is to close ConnectWise while the other application is running.

Running the following:

launchctl unload /Library/LaunchAgents/connectwisecontrol-xxxxxxxxxxxxxxxxx-onlogin.plist

That closes the ConnectWise Agent running in the background and allows the other application to work fine.

My ideal solution would be to use Automator or create or package a script that runs that command and then kicks off the other application when the user clicks it.

The part that I'm unsure of is how to write a script that finds the plist. The xxxxx's in that file vary depending on the computer. I need to search for that plist and then insert it into the unload statement.

Any guidance would be greatly appreciated!

Vernon
0
Hello experts,
I need to launch an AutoHotkey once I turn on my machine:
The idea is to place the following at:
AutoCorrect1:="C:\P\LD-autocorrect.ahk"
AutoCorrect2:="C:\F\LD-autocorrect.ahk"

If (FileExist(AutoCorrect1))
  Run,%AutoCorrect1%
Else
If (FileExist(AutoCorrect2))
  Run,%AutoCorrect2%
Else
  MsgBox,4112,Fatal Error, AutoCorrect does not exist on your system.
Return

Open in new window


I am aware that I can put: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
However I need to add some text at this file as a result I cannot place this file at this folder.

What is the best strategy:
1-Put a single AutoHotkey file at: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup to  automatically call autocorrect?
2-Create an AutoHotkey within my AutoHotkey file to run the autocorrect file? such as #!a:: however I need to remind every time that I need to launch this AutoHotkey to use autocorrect

Thank you for your help.
0
Hello experts,
I am trying to build the following AutoHotkey to send current dir based on Notepad ++ or Powershell:
:?*:cdx::
If (WinActive("ahk_exe notepad++.exe"))
{
  CurrentDirBlock:= "set CurrentDir=`%~dp0 `n" 
                  . "Rem Example: Base=%CurrentDir%Subfolder"
}          
If (WinActive("ahk_exe powershell_ise.exe"))
{
  CurrentDirBlock:= "$CurrentDir = Split-Path $script:MyInvocation.MyCommand.Path `n"
                    . "#Example: $Root = $CurrentDir + '\Root2'"
}
SendRaw %CurrentDirBlock%
Else
  MsgBox,4144,Error,Active window is not a supported program
Return

Open in new window

I don't understand why I have an error message If I put the final Else:
ELSE with no matching IF
And if I remove it I am able to launch the script.
If you have advice please let me know.
Thank you for your help.
0
Hello experts,
I have the following AutoHotkey which allows me to send a comment block:
:*:blc::
FormatTime,CurrentDateTime3,,yyyy/MM/dd HH:mm:ss
If ((WinActive("ahk_exe excel.exe")) or (WinActive("ahk_exe vbsedit.exe")))
  CommentBlock:="' *************************************************************************`n"
              . "' Author: `n"
              . "' Creation date: " . CurrentDateTime3 . "`n"
              . "' Description:`n"
              . "' ***************************************************************************`n"
Else
If (WinActive("ahk_exe notepad++.exe"))
  CommentBlock:="Rem ======================================================================`n"
              . "Rem Author: `n"
              . "Rem Creation date: " . CurrentDateTime3 . "`n"
              . "Rem Description:`n"
              . "Rem ======================================================================`n"
Else
If (WinActive("ahk_exe powershell_ise.exe"))
 CommentBlock:="# ===========================================================================`n"
              . "# Author:  `n"
              . "# Creation date: " . CurrentDateTime3 . "`n"
              . "# Description:`n"
              . "# ===========================================================================`n"
Else
If (WinActive("ahk_exe sciTE.exe"))
 CommentBlock:=";====================================`n"
              . ";`n"
              . ";====================================`n"
Else
If (WinActive("ahk_exe

Open in new window

0
Hello experts,

I was wondering how to properly have the coordinates of MouseClick to set up in AutoHotkey.
Screenshot tools display the coordinates when I take screenshot but those coordinates are not the one to set up.
I was thinking to set up something like this:
Reference site:
https://www.autohotkey.com/boards/viewtopic.php?t=33242#p154525
+^F12::
	ToolTip, click somewhere
	KeyWait, LButton, D
	MouseGetPos, X1, Y1
	KeyWait, LButton, U
	ToolTip,  click somewhere else
	KeyWait, LButton, D
	MouseGetPos, X2, Y2
	KeyWait, LButton, U
	ToolTip
	MsgBox, X1: %X1% Y1: %Y1% X2: %X2% Y2: %Y2%
Return

Open in new window

However I don't know if there is a potential risk to add this to my AutoHotkey file as regards the options used such as:
KeyWait and Tool Tip.
If you have advice on this please let me know.
Thank you for your help.
0
I am writing a cmd file to utilize robocopy as an automated backup. I want to create a new log every time it runs that is date stamped as part of the log name. I am using the script below. The log was named Tue09172019-8212265Home. However I want the format to be yyyymmdd-hhmm so in this case 20190917-0821Home.


set tdate=%date: =%
set tdate=%tdate:/=%
set ttime=%time::=%
set ttime=%ttime:.=%
set ttime=%ttime: =%


Robocopy G:\Home F:\Home /e /b /xo /copyall /dcopy:DAT /mt /LOG:F:Logs\%tdate%-%ttime%Home.log /NFL /NDL
0
Hello experts,
I am trying to understand the logic behind WinMaximize however the documentation available at:
https://www.autohotkey.com/docs/commands/WinMaximize.htm
is not enough for me.
The need is to set a WinActive condition, maximize and send a click:
Like this:
If (WinActive("ahk_exe ssms.exe"))
{
 WinMaximize
 MouseClick, left, 55, 233
 Return
}
Else
{
  MsgBox,4144,Error,Active window is not a supported program
  Return
}

Open in new window

Thank you for your help.
0
Hello experts,
I have the following AutoHotkeys:
;====================================
; Copy current line
;====================================

+^c::
Send {END}+{Shift}+{HOME}^c{Right}
Return

;====================================
; Cut current line
;====================================

+^x::
Send, {END}+{HOME}^x{Right}
Return

;====================================
; Duplicate current line 
;====================================

+^d::
Clipboard:=""
Send, {End}+{Home}^c
ClipWait,1
Send, {Right}+{Enter}^v 
Return

;====================================
;Remove a line
;====================================

+^r::
Send, {End}+{Home}+{Delete}
Return

Open in new window


I was thinking to modify the keys by hoststrings as I those keys combination are also part of other shortcuts keys already set up in another application such as MZ-tool.
I am aware that hoststrings is not the best for select text and I also test the following and it doesn't work when the cursor is at the beginning of the line.
;====================================
; Copy current line
;====================================

:*:lc::
Send {END}+{Shift}+{HOME}^c{Right}
Return

I am little confused and I would like to have your opinion on this.
Thank you for your help.
0
Hi,

I need to import users info from csv. The problem is the date format in lastlogon header from the csv, like:

4/22/2019 5:00:30 AM (180 days ago)

When I will do:

$users | Select SamAccountName,Lastlogon


How can I keep just the date  and not the number of days, like: 4/22/2019 5:00:30 AM?
1
Can someone please help us with a bat script that will wait 5 minutes and then return a 0 on success?

We need to call the script from this registry key : HKLM\Software\Citrix\MachineIdentityServiceAgent\ImagePreparation\After

The values are expected to be an executable or script (bat), returning 0 on success

Basically we need to VM to wait 5 minutes before it's shutdown by the system on returning a 0 on success the shutdown will triggered.  

Thank you!
0
Hi,


I just wondering if they more efficent or simple way top code this. I just want to change AD info based on info in csv file:
 
------------------------------------------------------------------------------------------------------------------------------
c:\userinfo.csv contains: SamAccountName,Name,Surname

$UsersInfo = Import-CSv -Path c:\userinfo.csv

$UsersInfo |%{

   $ADuser = Get-ADUser $_.SamAccountName | Select -ExpandProperty SamAccountName,Name,Surname


   If ($ADuser.SamAccountName -ne $_.SamAccountName ){ set-ADuser $ADuser.SamAccountName -SamAccountName $_.SamAccountName}

   If ($ADuser.Name -ne $_.Name ){ set-ADuser $ADuser.SamAccountName -Name $_.Name}

   If ($ADuser.Surname -ne $_.urname){ set-ADuser $ADuser.SamAccountName -Surname $_.surname}

}
------------------------------------------------------------------------------------------------------------------------------

Is it ok just to use many IF or there is more simple way?
0

Scripting Languages

28K

Solutions

21K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.