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. powershell scripts

    in AntiVirus, Firewalls and System Security
    powershell scripts: Hi, I have azure. Someone is somehow installing powershell scripts onto my computer that allows them to host my PC through P2P and UDP connections, well I think so anyway. I have only just found powershell script entry changes in my registry by accident. These criminals...
  3. 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...
  4. 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)....
  5. 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...
  6. System.Net.WebClient in .bat problem with download zip file Powershell

    in Windows 10 Support
    System.Net.WebClient in .bat problem with download zip file Powershell: Hello, I'm preparing a .bat file that downloads few files. I encountered a problem with downloading a larger file. Perhaps it is not the size of the file but a specific link. Well, in the bat file I use the command: Code: powershell.exe -Command "(New-Object...
  7. Running PowerShell script as a batch file

    in Windows 10 Network and Sharing
    Running PowerShell script as a batch file: Can I run the Power Shell line: "C:\Windows\System32>get-appxpackage *3dbuilder* | remove-appxpackage" from a .Bat file? ***Original title: Removing bloatware***...
  8. Unable to associate extensions/file types with BAT scripts

    in Windows 10 Software and Apps
    Unable to associate extensions/file types with BAT scripts: Using the assoc and ftype commands, I was always been able to associate certain extensions/filetypes with certain Batch scripts. But, this didn't appear to be be working in Windows 10. The following commands (run in a Admin command prompt) work fine in Windows 8.1 but not...
  9. Learning Powershell, for an old DOS BAT-file guy

    in Windows 10 Support
    Learning Powershell, for an old DOS BAT-file guy: So I go back to the days of DOS 6.2, and I've done a lot of BAT files since .*Nerd But I keep reading about Powershell. I've looked at some MS webpages for learning Powershell, and the learning curve seems pretty steep.*Sick Can anyone suggest a way to get started easily,...
  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...