Jump to content

Displaying text string in CMD file

MrBaker89

Hello Guys, 

 

I have a CMD file setup to run a powewrshell script when the user logs on to map network drives.

 

-Command "Set-ExecutionPolicy -Scope CurrentUser Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1 

-File "%SystemDrive%\Scripts\MapDrives.ps1" >> "%TEMP%\StartupLog.txt" 2>&1

 

I would like to add text at the start to warn the user not to close this window and then add text to the bottom once complete

 

Can I use the ECHO function or do I need to use something else? 

Ryzen 9 7900X

Asrock X670E PG Lightning 

32GB G.Skill 6000mhz DDR5

1TB Samsung 990 Pro 

Rdna 2 iGPU 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

You could also put the text in separate text files and say something like

 

COPY filename  CON 

 

con being the name for CONSOLE, the command window... but you'll see at the end of the text the message "1 file(s) copied", which is outputted by the copy command

You can hide that message by redirecting the output of copy command to NUL device (the text continues to be sent to command prompt)

 

COPY filename CON >NUL

 

and if you don't want the commands to be echoed back to to user you can say

 

@echo off

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×