Windows 10: Pass an argument from a .bat file to PowerShell script

Discus and support Pass an argument from a .bat file to PowerShell script in Windows 10 Support to solve the problem; I have subscribed to a push notification service in order to be able to send push notifications to my phone. Here is the PowerShell script: Code: $uri... Discussion in 'Windows 10 Support' started by Atom1, Dec 25, 2020.

  1. Atom1 Win User

    Pass an argument from a .bat file to PowerShell script


    I have subscribed to a push notification service in order to be able to send push notifications to my phone.
    Here is the PowerShell script:
    Code:
    I have not included the actual token or user values, but when I do, and I call this from a .bat file, it works.
    Here is the .bat file:
    Code:
    What I want to be able to do is insert a text message into the .bat file and pass it to the powershell script. The text could be a literal string or a file reference.
    How would I do either?
    Thanks.
    Windows 10 Pro 18363.1139

    :)
     
    Atom1, Dec 25, 2020
    #1
  2. Lucasonas Win User

    BAT file/Script to find and replace files

    FordGT90Concept!!!

    Your attachment is very close, it kept all the 5 numerals intact, but like you said: "it will rename them all from "#_Example_720p.zip" to "RAT_Example_#_24f_ONO.zip"...

    Greetings, Streetfighter 2

    I can't seem to get the BAT to work, but I'll still keep on trying.


    Any other suggestions, or BAT scripts Streetfighter & FordGT90Concept?
     
    Lucasonas, Dec 25, 2020
    #2
  3. BAT file/Script to find and replace files

    Hey all....

    Can someone help me make the BAT script in the 2nd post above to be able to use MORE than "1" file?
    As it currently is, you can only replace one particular file.

    For example, I want in the command line to be able to write two files or more, and the script will find and replace all those 2 or more named files.
    Thanks much.

    P.S.... Is there a GUI that does file searching and replacing?
    I've spent hours searching on the net, and the only thing I can find are "text" search/replace and this BAT command, not actual "file" replacing. I find this amazing. *Frown Pass an argument from a .bat file to PowerShell script :(
     
    leeuniverse, Dec 25, 2020
    #3
  4. Lucasonas Win User

    Pass an argument from a .bat file to PowerShell script

    BAT file/Script to find and replace files

    Hi, innovative thinkers! I am looking for a BAT file or script that takes random named zips, consisting of 5 random numerals in the name, and renames the zips identical to different .txt files with that same 5 numeral in the same folder.

    Here is an example of what I mean:

    BEFORE BAT

    C:\Documents

    45678_Example_720p.zip
    34284_Example_720p.zip
    67483_Example_720p.zip

    RAT_Example_45678_24f_ONO.txt
    RAT_Example_34284_24f_ONO.txt
    RAT_Example_67483_24f_ONO.txt

    AFTER BAT

    C:\Documents

    RAT_Example_45678_24f_ONO.zip
    RAT_Example_34284_24f_ONO.zip
    RAT_Example_67483_24f_ONO.zip

    RAT_Example_45678_24f_ONO.txt
    RAT_Example_34284_24f_ONO.txt
    RAT_Example_67483_24f_ONO.txt

    I would like the BAT to take only those matching 5 numerals as a reference.

    Thanks

    *Oh Well Pass an argument from a .bat file to PowerShell script :eek:hwell:
     
    Lucasonas, Dec 25, 2020
    #4
Thema:

Pass an argument from a .bat file to PowerShell script

Loading...
  1. Pass an argument from a .bat file to PowerShell script - Similar Threads - Pass argument bat

  2. Passing argument to the application does not work

    in Windows 10 Gaming
    Passing argument to the application does not work: Hello,I found strange behaviour on Windows 11, which caused problems during the application start. I have my own application that accepts some arguments on the input. I have an association in the registry Computer\HKEY_CLASSES_ROOT\MyApplication.psi\shell\open\command for...
  3. Passing argument to the application does not work

    in Windows 10 Software and Apps
    Passing argument to the application does not work: Hello,I found strange behaviour on Windows 11, which caused problems during the application start. I have my own application that accepts some arguments on the input. I have an association in the registry Computer\HKEY_CLASSES_ROOT\MyApplication.psi\shell\open\command for...
  4. PowerShell script

    in Windows 10 Support
    PowerShell script: The code below tests a series of IPs in a txt file.The result is as follows and is written in a txt file. 19.191.12.161 - online 19.191.12.162 - offline 19.191.12.163 - offline 19.191.12.164 - offline 19.191.12.165 - offline also see the scrennshot Code: $Output= @()$GetIP =...
  5. Bat script to select a folder and update the path in a bat file

    in Windows 10 Support
    Bat script to select a folder and update the path in a bat file: How do I combine this scripts? i want the highlighted folder path to been passed in to the script that's been generated (rensa_datafiler.bat) Its begins with you select a folder: @Echo off Title Folder Selection echo( Select folder . . . call:FolderSelection "%SourcePath%",...
  6. Create a .bat or script file for the following actions.

    in Windows 10 Network and Sharing
    Create a .bat or script file for the following actions.: So I have a app called AltServer that occasionally "dies" and doesn't work with my phone. So a "fix" I "found" is to kill the old, the currently running Altserver.exe and rerun Altserver.exe with administrator privileges. So, can anyone help me create a .bat file or some kind...
  7. powershell script

    in Windows 10 Customization
    powershell script: looking for a script to monitor for a folder, if there is a file in that folder send it as an email, once the email is sent out, confirm and then move the files to an archive folder. monitor c:\test\*.pdf No files, do not send email. Yes Files, send an email to someone at...
  8. Passing parameters in a bat file

    in Windows 10 Support
    Passing parameters in a bat file: I am trying to run a bat file from a desktop shortcut. If I run it from DOS it works fine. If I try to run it from a desktop shortcut, I can not pass the parameter inside the bat file. See attached for the example of the bat file. The first part works (from the DOS prompt)....
  9. Pass partial parameter in bat file

    in Windows 10 Support
    Pass partial parameter in bat file: I have about 200 files examples: 20200101 FILE10.TXT 20200102 FILE10.TXT 20200103 FILE10.TXT 20200104 FILE10.TXT I need a way to accept only the first 8 positions in a bat file and copy the whole file to another directory. If enter 20200101 and it will pass the file...
  10. PowerShell Scripting - Run a Script from Shortcut

    in Windows 10 Tutorials
    PowerShell Scripting - Run a Script from Shortcut: How to: PowerShell Scripting - Run a Script from Shortcut [img] Information One of many PowerShell security features is that you can't run a script simply by double clicking it's icon on desktop or in a folder. Doing so will by default open script in Notepad for editing...