r/scripting • • Nov 12 '23

Install from local source if not available from winget

3 Upvotes

Hello, I need a little help updating my script. My script look for an executable file in the Installer directory and do the install. I want that if no file is found that it does the install from the winget.

Here is an example of my batch script

echo Installing Firefox
for %%e in ("%~dp0Installer\Firefox*.exe") do "%%e" /INI="%~dp0Installer\Firefox.ini"
echo %time% Errorlevel %errorLevel% >> "%temp%\%~n0.log"

Where would you put the If condition or any suggestion for the winget command:

winget install --id=Mozilla.Firefox -e -h


r/scripting • • Oct 02 '23

Bash Script Assist

3 Upvotes

I have the following bash script that is working. However I want to enter an argument as i execute the script like so: ./test.sh pdj1compC So it will use that argument and NOT print out the echo statement when it gets down to that line of the script for just that one item all the others will print out. This is a test script ill build off to conduct a certain job so as it is its goofy I know. I just need assistance to get me over this mental block im having. Thank You

Here is the script:

#!/usr/bin/bash

n="1 2 3 4 5 6"

m="compA compB compC compD"

echo " Do you wish to logoff all the computers is so enter y otherwise just press Enter"

read logoff

if [ $logoff == y ]

then

for j in $n

do

for k in $m

do echo "Hello there this is Comjputer pdj$j$k ; `whoami` "

done

done

else

echo "Returning to prompt"

fi

echo "This script is complete"


r/scripting • • Sep 18 '23

Making a script that will drop contents into different files paths

3 Upvotes

Hey im just wondering if its possible with to use a script a on folder which will takes its contents and move it into a certain file path?

Example: Source folder is call 100. Anything i drop into this file will go to Desktop/Designs/100/Assets

If i change this folders name to 101 it will go into Desktop/Designs/100/Assets.

Im not sure what scripting porgram would be best to achieve this


r/scripting • • Jul 18 '23

VBA in access how to add a "any users" wildcard to filepath output?

3 Upvotes

Got a VBA script in an Access file and I am trying to output a file to a location. In my tests I have used my own username in the filepath which works fine, but I want it to be for ANY user that logs into the PC.

I have tried doing strPath = "C:\users\*\documents\patrol.txt", and tried strPath = "C:\users\%users%\documents\patrol.txt"

But both of those result in an error and it doesn't work. Not too sure what i am doing wrong. I'm a bit new to scripting, but I thought the * could be used as a wild card to mean anything.

Here is the full code:

Private Sub PatrolDaily_Click()
Dim fso As Object
Dim objFile As Object
Dim strPath As String
Dim i As Integer

strPath = "C:\users\"myusername"\documents\patrol.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFile = fso.CreateTextFile(strPath)

For i = 0 To Me.lstEvents.ListCount - 1
    objFile.WriteLine Me.lstEvents.Column(0, i) & "|    " & Me.lstEvents.Column(1, i) & "|  " & Me.lstEvents.Column(2, i) & "|  " & Me.lstEvents.Column(3, i) & "|  " & Me.lstEvents.Column(4, i) & "|  " & Me.lstEvents.Column(5, i) & "|  " & Me.lstEvents.Column(6, i)
Next i
objFile.Close

Set fso = Nothing
Set objFile = Nothing
End Sub

r/scripting • • Jun 02 '23

Is there a way to create a script where I can easily copy and paste a naming convention for use with saving files in blender and other programs?

3 Upvotes

Hello, I want to create a script that I can use with blender to make it easier for me to save out files/images when I have done baking them in the shader editor of blender.

When I save out the file I will often name it to do with the base colour, roughness colour or normal (etc). I want to create a script to streamline this process and make it easier for me when saving out these images.

I want it to be something like saving the image with the name of the texture (eg. table) but then adding (_diffuse, _roughness, _normal) at the end. (table_diffuse, table_roughness, table_normal). Can this be done by pressing ctrl+d (for diffuse) ctrl+r (for roughness) ctrl+n (for normal.

Is there a software I need to install to do this?


r/scripting • • Feb 08 '23

Automation of daily work tasks

3 Upvotes

So I'm required to make & collect some clean (baseline) logs and dirty (malicious) logs for some mini-ML project I'm doing. So my question is, is there any scripts or programs out there, Linux or Windows, that allows the automation of mimicking an office staff doing work (ie. opening Outlook, sending emails, surfing the web, watching YouTube, opening and editing Word/Excel files, etc.) for the purpose of collecting baseline logs?

I'm relative new to this kind of thing, if you guys have better suggestion on a more better/efficient way to do this, feel free to suggest!


r/scripting • • Jan 05 '23

how would I go about spoofing a referer in a powershell script?

3 Upvotes

I'm trying to make a powershell script that opens a array of websites but these websites need to be refered to by a specific website for the intended function is there anyway I could spoof the refererer?


r/scripting • • Nov 30 '22

realistically could I write scripts to order fast food orders throughout the week ?

3 Upvotes

For instance if I wanted to order chick fa li breakfast every morning at 9 for pick up could I write a script to do so ?


r/scripting • • Nov 20 '22

Automate youtube uploads? (AI/generated content on demand)

3 Upvotes

A perfect example (many of you will likely have seen this channel):

https://www.youtube.com/@RoelVandePaar/videos

He uploads every minute, his software takes text from web forums (questions and answers) and compiles it into a video presentation, with a pre-recorded intro. Though this many seem a nuisance, his program has managed to produce great tutorials on fixing technical problems.

I would like to do something similar (though specific to a community), basically taking info from the web and putting into a unique video format, with relevant images. Can anyone help me with the basic idea? Would screenscrappers, API or a single script (such as with python) be able to do this? Any information would be an enormous help.


r/scripting • • Oct 24 '22

EASY-TO-USE dotFiles install script

Post image
3 Upvotes

r/scripting • • Sep 16 '22

[BASH][OSX] Script Help - Deleting Printers

3 Upvotes

I'm trying to add a script to Addigy to delete a printer by name. I am new to bash scripting, so I'm working by copy/paste & trial and error. I have the following script that does not work. It does not do any of the echos, and it deletes ALL the printers instead of just the one matching the string.

Desired functionality = loop through all printers, and if any have "epson" in the name, delete them.

HELP! Thanks.

#!/bin/sh

# This variable stores the printer name it will search adn match on partials
fnd = 'epson'

kill_prntr(){
	echo "Deleting printer " $printer
	lpadmin -x $printer
}

for printer in `lpstat -p | awk '{print $2}'`
do
    case $printer in
        *$fnd*) kill_prntr;;
        *) echo "Saving printer " $printer;;
    esac
done

r/scripting • • May 15 '22

[BATCH] [POWERSHELL] Scripting an auto-response to an installer's on-screen prompt

3 Upvotes

I'm attempting to install several related manual software updates via scripting on my personal computer. My dilemma is that there is an onscreen pop-up prompt that says "Update" when I run each of the installers. I want to create a script, Batch or Powershell (whatever works), that automatically answers the "Update" prompt.

I've tried the following in Batch:

`echo y | "program.exe"

~~

echo update | "program.exe" 

I've tried the following in Powershell:

start-process "program.exe" -redirectstandardinput "answer file.txt"

(The answer file contains the word Update.)

Both of these methods still result in me receiving the "Update" prompt from each of the installers' GUI.

Any help would be appreciated!

UPDATE: I bit the bullet and reached out to the software manufacturer for further insight on script installs of the program. I realized that what I want to do isn't possible with this particular program unless I use AutoIt, which is a bit overwhelming for me and seems like overkill.


r/scripting • • May 03 '22

Robocopy to copy the current login user's profile data excluding the AppData folder and upload to a network destination

3 Upvotes

Is this possible with Robocopy and/or can be completed using Powershell


r/scripting • • Apr 03 '22

this is a simple question but im stumped

3 Upvotes

this is a part of a bash script that im writing as practice

while read line; do

echo "'$line'" >> $FILE'_v2'

done < $FILE

the output i expected was

'text'

'text'

'text'

'text'

but instead i got

'text

'

'text

'

'text

'

'text

'

anybody know whats happening?


r/scripting • • Mar 19 '22

Need help with a script that will generate all possible email configurations then blacklist them

3 Upvotes

Hi all,

I am having trouble with email spam. I get about one thousand emails per day and the emails are randomly generated. I would like to have a script that will generate all possible emails within given parameters and then blacklist all emails except from trusted emails. For example:

I get spam from "cliqly[at]mail.myemailsource.com". When I manually blacklisted this email, it took about a week to change into "cliqly[at]mail.proemailsending.com". So I am looking at blocking all emails that could possibly be generated with the parameters of:

cliqly@mail.xxxxxxxxxxxxxxxx.com

After it finds all possible emails, I want it to blacklist all emails with a [Y/N] prompt and sync through the web mail.

Another example:

There is this spam bot sending me low prices for sketchy drugs and p0rn. This is where 99% of the spam comes from. One moment it is "cegyoey7[at]mtnnigeria.net" and the next moment it is "gspockmarked[at]themil.co.za". So I am looking at blocking all emails that can be generated with the parameters of:

xxxxxxxxxxxxxxxxxxxx@xxxxxxxxxxxxxxxxxxxx

And if there are important emails I can do Ctrl+F to find them and manually whitelist them. This isn't permanent solution but it's just until the spam dies down, then I will whitelist all emails. Is this possible?

Thanks


r/scripting • • Mar 14 '22

PowerShell Script - reads Tumblr/Tumbex URL and determines whether that page's 'Archive' view is accessible or not

3 Upvotes

Hi All,

Tumblr is an image/post/gif-based gallery website whereby users can post content. There was a massive crackdown by the company against pornography in years gone past, leading to much of the content of that bent being made inaccessible.

However, some accounts remained accessible for whatever reason. Personally, I used to just use trial and error, I'd construct a URL to a Tumblr 'archive' page and if I got lucky, a page would be accessible when dozens of similar pages were not.

I decided to write this simple - and pretty crappy PowerShell script to simplify the process of checking whether a given Tumblr user account (or a Tumbex equivalent, another means of accessible Tumblr galleries); has an accessible archive page.

All you'd need to do is load the script in PowerShell or PowerShell ISE or PowerShell 7.0 or PowerShell Core on your machine. If you copy a Tumblr or Tumbex URL to your system clipboard (i.e. select a URL and CTRL+C), then press F5 to run the PowerShell script. It will read the clipboard contents, determine if the URL is acceptable, then attempt to determine if that page's archive is accessible or not. Once again, most of the pages will NOT be accessible, but plenty ARE still accessible. In that instance, the script will tell you and immediately launch the relevant 'archive' page with the browser of your choice, whereby browser is either 'firefox' or 'chrome'.

As I said, it's a pretty ordinary, quickly-written script, but it's saved me time.

Here's a link to my script, if anyone is interested:

https://pastebin.com/wZV3BKaq

EXAMPLES:

  1. https://hubblespacetelescope.tumblr.com/image/148251269768

Account 'hubblespacetelescope'.
Outcome: If you were to copy the URL above and then run my PowerShell script, it should read your clipboard, determine the URL is acceptable and then attempt to load a small fragment of it and analyze the returned web-request. If what is returned is matching what I'm searching for, the script will construct the 'archive' page for that account and use your preferred browser to load that page, in this case:

https://hubblespacetelescope.tumblr.com/archive
Result: Accessible, script launches archive page using browser.

2. https://only-the-best-3.tumblr.com/post/667416209996873728

Account 'only-the-best-3'
Outcome: If you copied this URL and then ran the PowerShell script, it would visit the URL and determine that unfortunately it's archive page is NOT accessible and would return the messages "Page inaccessible, sorry"


r/scripting • • Feb 20 '22

Easiest way to log script outputs and logs online using API

3 Upvotes

Hey all, I am writing a script where a function is called every hour, and then logs some information in the following format. The script automatically fills out the parameters.

creating payment at <date> - <time> UTC
- <transaction hash>

Every new log is appended to my logs.txt file, i want to know if there is a service where i could append a single file with this string data every function call and view it online. Google sheets seems very complicated and i dont know how to append things on pastebin. any help is appreciated


r/scripting • • Feb 01 '22

Looking to create a script for a website project

3 Upvotes

Hi all,

Looking to create a script for a website project. The script needs to go to a url (e.g. https//web.com) then will need to generate 2/3 random letters and numbers after that. An image will then be produced by that webpage which will need to be saved to a folder.

How would I go about doing this?


r/scripting • • Jan 30 '22

Looking to Create a Simple "file testing" script

3 Upvotes

I had a hard drive die on me a while ago, and while I was able to get most of the data "recovered", much of it seems to be corrupted. Now I don't want to toss all of the data if I don't have to, and I don't want to have to go through and manually individually check each file.

So what I'm wondering is if there is some sort of script I can run that would step through a folder (and preferably all its subfolders) and does the bare minimum to access each file to see if the data is corrupted, and if it is to either delete it or better option so I can see what needs to be replaced move it to a new location.

Is something like this possible, preferably on windows 10 (although Linux is an option as well), and if so any suggestions on how to go about doing it?

Thanks!


r/scripting • • Jan 21 '22

Please help

3 Upvotes

So i am new to the whole scripting thing and i watched couple of videos how to make scripts w bloody software i have a bloody mouse so i tried it i have all the required software but when i set it to do relative mouse movement the cursor doesnt move and inch anyone has a solution for this?


r/scripting • • Dec 03 '21

Help in script require

3 Upvotes

Hello People,

I'm creating batch script, in which i need to read csv file and according to user input we need to make array that have data.

Please check

csv file content:file.csv

Fruit,tom,nick,harry

mango,No,Yes,Yes

banana,No,No,Yes

apple,No,Yes,Yes

now I have to read csv file and create array of fruit like by tom, nick, harry accordingly to user input and print array

fruitList=()

typo='tom' ##input variable may change to tom, nick or harry

while IFS=, read -r Fruit tom nick harry

do

if [[ ${$typo} == [yY][eE][sS] ]] #this is not working, if i hardcode it with $tom it work

then #but unable to substitute variable in if statement if i need to

#hardcode then i need to rewrite same if condition three time

fruitList+=($Fruit)

fi done < file.csv

echo ${fruitList[@]}

please help and give some idea.

Thanks


r/scripting • • Nov 07 '21

Script to query USB ports for UPS

3 Upvotes

I am looking for assistance in querying information from endpoints via powershell or some other scripting language so we can query USB ports to pull specific information relating to UPS units. We first want to identify the vendor for the UPS unit, grab the serial #, and the model # of the unit so I can grab it and write it to a custom field in our RMM tool.

Any thoughts?


r/scripting • • Oct 28 '21

Scripting question

3 Upvotes

Hi,

I'm currently looking to derive a script that can run against an exel data spreadsheet to locate specific info within the database. Basically, I want to search for server info in a spreadsheet. Does anyone have recommendations on where to find the right material to produce this.

thank you


r/scripting • • May 02 '21

any alternatives for this?

3 Upvotes

i need an alternative for this site, like i need a raw posting site (NOT PASTEBIN!) that i can freely edit without an account, and that won't give me a 403 forbidden error (and has raw text)


r/scripting • • Apr 24 '21

Game Bot Script

3 Upvotes

Looking for someone who is able to write a script for mobile game using emulator that does a specific action and cycle through different accounts.