Is it possible to setup a Windows .BAT
file in such a way so that it's possible to execute when called from CMD
, but does not run when someone double-clicks the file?
Normal view
- Change route color in terminalDoes anyone know how I can have that colored background in my routes, in the github branch and the icons. I currently use the Hyper terminal with the dracula theme Terminal currently: For example:
- Can I prevent a Windows batch file from execution through a double-click?Is it possible to setup a Windows .BAT file in such a way so that it's possible to execute when called from CMD, but does not run when someone double-clicks the file?
Can I prevent a Windows batch file from execution through a double-click?
- When i try use 'composer update' in my project i received this error: curl error 60When i try install dependecies from my Laravel project, i received this error: I've tried to install my composer packages but I cant use almost any composer command because of an error of cURL in my computer I've already tried to download and install the CA from others StackOverflow posts but any success All I want is run composer update without the error on cURL The errror I was talking about: [Composer\Downloader\TransportException] curl error 60 while downloading https://repo.packagist.org/p
When i try use 'composer update' in my project i received this error: curl error 60
When i try install dependecies from my Laravel project, i received this error:
I've tried to install my composer packages but I cant use almost any composer command because of an error of cURL in my computer
I've already tried to download and install the CA from others StackOverflow posts but any success
All I want is run composer update without the error on cURL
The errror I was talking about: [Composer\Downloader\TransportException] curl error 60 while downloading https://repo.packagist.org/packages.json: SSL certificate problem: unable to get local issuer certificate Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks. Checking github.com rate limit: FAIL [Composer\Downloader\TransportException] curl error 60 while downloading https://api.github.com/rate_limit: SSL certificate problem: unable to get local issuer certificate
- Writing over already existing characters in the Windows console using cppI am trying to render a video in ascii art, using c++ in the windows console. However, clearing the screen and drawing the entire frame again is far too slow for the windows console, and also creates a massive flickering affect at the bottom of the screen. When I was trying to find a solution for this, I found this stack overflow question which appeared to have the answers I needed with this code (Where setCursorPosition moves the windows console cursor to an x and y position) for (int y = 0; y
Writing over already existing characters in the Windows console using cpp
I am trying to render a video in ascii art, using c++ in the windows console. However, clearing the screen and drawing the entire frame again is far too slow for the windows console, and also creates a massive flickering affect at the bottom of the screen. When I was trying to find a solution for this, I found this stack overflow question which appeared to have the answers I needed with this code (Where setCursorPosition moves the windows console cursor to an x and y position)
for (int y = 0; y != MAX_Y; ++y)
{
for (int x = 0; x != MAX_X; ++x)
{
if (asciiChart[frameNum][x][y] == asciiChart[frameNum + 1][x][y]) {
continue;
}
setCursorPosition(x, y);
std::cout << asciiChart[frameNum + 1][x][y];
}
}
std::cout.flush();
However, this code leads to massive artifacts, such as not clearing some already existing pixels(even though I have empty spaces in my ascii chart), rendering text outside the bounds of the video, and creating new lines throughout execution. I have already verified the frames of my video are correct(Being represented as a vector of strings, where each string represents one row of pixels), so why does this code not work?
- Interrupt HandlingI want to create a priority based interrupt handler for real time events in windows . Its my OS project. What software am I supposed to use? Help me start with my project. I want to know the software to use for my project and the code guidance.
Interrupt Handling
I want to create a priority based interrupt handler for real time events in windows . Its my OS project. What software am I supposed to use? Help me start with my project.
I want to know the software to use for my project and the code guidance.
- Angular second times api not show in Network tab/ chromeI want to call GET api the first time it was called, but second times api not show in Network tab/ chrome. So I don't know whether angular interceptor block it? receiptCardVoucherList(pageno:number,shift:any,day_shift:any,petro_id:number){ this.http.get(constDefault.API_URL+'/petros/receiptCardVoucherList/page:'+pageno+'/'+shift+'/'+day_shift+'/'+petro_id+'/'+this.login_year,{headers:this.headersdata}).subscribe(alldata => { console.log('https services site ',alldata)}); //if(alldata){ return
Angular second times api not show in Network tab/ chrome
I want to call GET api the first time it was called, but second times api not show in Network tab/ chrome. So I don't know whether angular interceptor block it?
receiptCardVoucherList(pageno:number,shift:any,day_shift:any,petro_id:number){ this.http.get(constDefault.API_URL+'/petros/receiptCardVoucherList/page:'+pageno+'/'+shift+'/'+day_shift+'/'+petro_id+'/'+this.login_year,{headers:this.headersdata}).subscribe(alldata => { console.log('https services site ',alldata)}); //if(alldata){ return this.http.get(constDefault.API_URL+'/petros/receiptCardVoucherList/page:'+pageno+'/'+shift+'/'+day_shift+'/'+petro_id+'/'+this.login_year,{headers:this.headersdata}) } old data show but not call second time
- How to upgrade pgAdmin 4 on windows?I installed pgAdmin 4 as part of the postgres installer for Windows. pgAdmin is now telling me there is a newer version (4.8, > 4.5 which I have). However, there is no built in upgrade functionality that I can see, and when I went to download and run the pgAdmin 4 installer to upgrade, it installed itself in the wrong place, leading to problems. At first I tried installing it to the default location (C:\Program Files (x86)\pgAdmin 4\v4), which was incorrect, because the previous installatio
How to upgrade pgAdmin 4 on windows?
I installed pgAdmin 4 as part of the postgres installer for Windows. pgAdmin is now telling me there is a newer version (4.8, > 4.5 which I have). However, there is no built in upgrade functionality that I can see, and when I went to download and run the pgAdmin 4 installer to upgrade, it installed itself in the wrong place, leading to problems.
At first I tried installing it to the default location (C:\Program Files (x86)\pgAdmin 4\v4
), which was incorrect, because the previous installation (from the postgres installer) went to a different location (C:\Program Files\PostgreSQL\11\pgAdmin 4
).
The second time, I pointed it to my existing install of postgres (C:\Program Files\PostgreSQL\11\pgAdmin 4
), but it installed itself to a subdirectory there instead (C:\Program Files\PostgreSQL\11\pgAdmin 4\v4
), rather than upgrading the existing installation, once again yielding to duplicated installations and problems arising from that. I assume if I go download the postgres installer, it will just reinstall version 4.5 of pgAdmin, though I have not tested this.
What is the correct method for upgrading a pgAdmin instance originally installed by the postgres Windows installer?
- I can't use GCC for some reasonSo i installed gcc using the tutorial from respectively visual studio c++ docs and msys2.org but after adding it to path and making sure everything should be fine it just wont work. when i run gcc --version it just says "gcc is not recognized as an internal or external file" I tried to look something up online but nothing really happened it might be a bad explanation but im new to this stuff
I can't use GCC for some reason
So i installed gcc using the tutorial from respectively visual studio c++ docs and msys2.org but after adding it to path and making sure everything should be fine it just wont work.
when i run gcc --version it just says "gcc is not recognized as an internal or external file"
I tried to look something up online but nothing really happened it might be a bad explanation but im new to this stuff
- Create Windows Service which just executes a java commandI need to create a Windows Service which is just executing a java command. The service needs to run permanently and should automatically start on system reboot. In the past, I had success doing it with nssm, but we are not able to use it in this environment as our customer does not want to have any external software installed on the system. In detail, we want to use the server as a Jenkins agent, so we have to execute the java command which brings up the connection to the controller. What would
Create Windows Service which just executes a java command
I need to create a Windows Service which is just executing a java
command. The service needs to run permanently and should automatically start on system reboot. In the past, I had success doing it with nssm
, but we are not able to use it in this environment as our customer does not want to have any external software installed on the system.
In detail, we want to use the server as a Jenkins agent, so we have to execute the java
command which brings up the connection to the controller.
What would be the best way to do this? Is there a simple way like with bat
? I also figured to create an exe
with C++ or maybe C#, but that would close the terminal after executing the command, leading to breaking down the connection, wouldn't it?
- AWS LocalStack - Installing & Configuring Locally on Windows for SQSThis article explains how to install and configure AWS LocalStack on a Windows machine for SQS (Simple Queue Service).
AWS LocalStack - Installing & Configuring Locally on Windows for SQS
- Temporarily replacing one pane of glass in a double-pane door โ diy.stackexchange.comI've got an old steel patio door with double-pane glass, and one side of the glass has many cracks in it. I'm afraid it's about to fall out at any moment. We have long-term plans to replace the ...
Temporarily replacing one pane of glass in a double-pane door โ diy.stackexchange.com
- Reorganize and Rebuild Indexes and Update StatisticsA simple stored procedure to add at your database to keep it reactive
Reorganize and Rebuild Indexes and Update Statistics
- Automatic Missing Indexes Creation StatementsAutomatic creation of non clustered indexes using system SQL entities
Automatic Missing Indexes Creation Statements
- Why will the second code block in powershell not execute?The first Script-block is executing without any issues however I am unsure why the second Script-block is not executing. Import-Module ThreadJob $streamMonitor = @( @{ directoryPath = "C:\path\stream1" scriptToRestartPath = "C:\path\stream1.bat" } @{ directoryPath = "C:\path\stream2" scriptToRestartPath = "C:\path\stream2.bat" } ) $streamMonitor | ForEach-Object { Start-ThreadJob -ScriptBlock { . C:\Users\luke_linwood_lo
Why will the second code block in powershell not execute?
The first Script-block is executing without any issues however I am unsure why the second Script-block is not executing.
Import-Module ThreadJob
$streamMonitor = @(
@{
directoryPath = "C:\path\stream1"
scriptToRestartPath = "C:\path\stream1.bat"
}
@{
directoryPath = "C:\path\stream2"
scriptToRestartPath = "C:\path\stream2.bat"
}
)
$streamMonitor | ForEach-Object {
Start-ThreadJob -ScriptBlock {
. C:\Users\luke_linwood_lopez\Desktop\ffmpeg-6.0-essentials_build\bin\streamMonitor.ps1
streamMonitor @using:_
} -ArgumentList @($directoryPath, $scriptToRestartPath)
} | Receive-Job -Wait -AutoRemoveJob
#This is the Block that will not execute
Start-ThreadJob -ScriptBlock {
while ($true) {
1..3 | ForEach-Object {
$directory = "C:\nginx\srv\hls\stream$_"
Get-ChildItem $directory -Recurse -File | Where-Object {($_.Extension -ne ".m3u8") -and $_.CreationTime -lt (Get-Date).AddSeconds(-30)} | Remove-Item -Force
}
Write-Host "Completed cleaning directories."
Start-Sleep -Seconds 30 # Wait for 30 seconds before running the command again
}
} | Receive-Job -Wait -AutoRemoveJob
- How to do I restart a batch file in powershell?Here is what I have tried: Get-Process | Where-Object {$_.Path -eq "C:\path\stream1.bat"} | Stop-Process -Force Start-Sleep -Seconds 5 Start-Process -FilePath "cmd.exe" -ArgumentList "/c `"C:\path\stream1.bat`"" The Start-Process command works perfectly however the Stop-Process command does nothing.
How to do I restart a batch file in powershell?
Here is what I have tried:
Get-Process | Where-Object {$_.Path -eq "C:\path\stream1.bat"} | Stop-Process -Force
Start-Sleep -Seconds 5
Start-Process -FilePath "cmd.exe" -ArgumentList "/c `"C:\path\stream1.bat`""
The Start-Process command works perfectly however the Stop-Process command does nothing.
- How to use AMSI_UAC_REQUEST_TYPE?Recently I implemented an Antimalware Scan Interface (AMSI) provider to intercept script execution, and scan script content before it executed. I based my code on the Microsoft sample AMSI provider. (Github). In amsi.h I found AMSI_UAC_REQUEST_TYPE enum with very interesting fields: typedef enum AMSI_UAC_REQUEST_TYPE { AMSI_UAC_REQUEST_TYPE_EXE = 0, AMSI_UAC_REQUEST_TYPE_COM = 1, AMSI_UAC_REQUEST_TYPE_MSI = 2, AMSI_UAC_REQUEST_TYPE_AX = 3, AMSI_UAC_REQUEST_TYPE_MAX
How to use AMSI_UAC_REQUEST_TYPE?
Recently I implemented an Antimalware Scan Interface (AMSI) provider to intercept script execution, and scan script content before it executed. I based my code on the Microsoft sample AMSI provider. (Github).
In amsi.h
I found AMSI_UAC_REQUEST_TYPE
enum with very interesting fields:
typedef enum AMSI_UAC_REQUEST_TYPE
{
AMSI_UAC_REQUEST_TYPE_EXE = 0,
AMSI_UAC_REQUEST_TYPE_COM = 1,
AMSI_UAC_REQUEST_TYPE_MSI = 2,
AMSI_UAC_REQUEST_TYPE_AX = 3,
AMSI_UAC_REQUEST_TYPE_MAX = 4
} AMSI_UAC_REQUEST_TYPE;
But I can't understand how to utilize it. Which callback should I use to intercept UAC request?
- How to Restart a USB PortShows how to use IOCTL_USB_HUB_CYCLE_PORT to restart a USB port under Windows
How to Restart a USB Port
- Compiling C file with MingW in Windows: The system cannot execute the specified programThe C file compiles perfectly fine as long as it's only: #include <stdio.h> int main( void ) { printf( "Hello, world without a new line" ); return 0; } and it outputs "Hello, without a new line." However, as I add more code to my program such as: printf( "Hello, world with a new line\n" ); and I try to compile it like this: gcc filename.c -o filename.exe then I receive the message "The system cannot execute the specified program." I checked if the PATH in the environment variables
Compiling C file with MingW in Windows: The system cannot execute the specified program
The C file compiles perfectly fine as long as it's only:
#include <stdio.h>
int main( void ) {
printf( "Hello, world without a new line" );
return 0;
}
and it outputs "Hello, without a new line."
However, as I add more code to my program such as:
printf( "Hello, world with a new line\n" );
and I try to compile it like this:
gcc filename.c -o filename.exe
then I receive the message "The system cannot execute the specified program."
I checked if the PATH in the environment variables is there for MingW/bin, I opened and closed applications if it was a memory issue, I have the McAfee antivirus installed.
- Compilation Issue with pnet Crate on Windows = note: LINK : fatal error LNK1181: cannot open input file 'Packet.lib'Description: I am attempting to compile a Rust program on a Windows machine that uses the pnet crate. Despite having installed all the required tools and dependencies, the compilation fails. Environment: OS: Windows 10 Rust Version: 1.72 Steps to Reproduce: Create a new Rust project with cargo new my_pnet_project. Add pnet crate to Cargo.toml. [dependencies] pnet = "0.25" # Replace with the version you want Run cargo build in the project directory. Expected Behavior: The project should compile
Compilation Issue with pnet Crate on Windows = note: LINK : fatal error LNK1181: cannot open input file 'Packet.lib'
Description:
I am attempting to compile a Rust program on a Windows machine that uses the pnet
crate. Despite having installed all the required tools and dependencies, the compilation fails.
Environment:
- OS: Windows 10
- Rust Version: 1.72
Steps to Reproduce:
- Create a new Rust project with
cargo new my_pnet_project
. - Add
pnet
crate toCargo.toml
.
[dependencies]
pnet = "0.25" # Replace with the version you want
- Run
cargo build
in the project directory.
Expected Behavior:
The project should compile without any issues.
Actual Behavior:
The compilation fails with the following error messages:
= note: /usr/bin/x86_64-w64-mingw32-ld: cannot find -lPacket: No such file or directory
collect2: error: ld returned 1 exit status
error: could not compile `atlantic` (bin "atlantic") due to previous error
Caused by:
process didn't exit successfully: `/home/erdt-cyber/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name atlantic --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=214 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=bc075ce29cde910a -C extra-filename=-bc075ce29cde910a --out-dir /home/erdt-cyber/Documents/gitHub/Atlantic/target/x86_64-pc-windows-gnu/debug/deps --target x86_64-pc-windows-gnu -C incremental=/home/erdt-cyber/Documents/gitHub/Atlantic/target/x86_64-pc-windows-gnu/debug/incremental -L dependency=/home/erdt-cyber/Documents/gitHub/Atlantic/target/x86_64-pc-windows-gnu/debug/deps -L dependency=/home/erdt-cyber/Documents/gitHub/Atlantic/target/debug/deps --extern csv=/home/erdt-cyber/Documents/gitHub/Atlantic/target/x86_64-pc-windows-gnu/debug/deps/libcsv-29d015f24057f58e.rlib --extern pnet=/home/erdt-cyber/Documents/gitHub/Atlantic/target/x86_64-pc-windows-gnu/debug/deps/libpnet-d2ad988bcd6db621.rlib --extern serde=/home/erdt-cyber/Documents/gitHub/Atlantic/target/x86_64-pc-windows-gnu/debug/deps/libserde-06112e241e2deea9.rlib -L native=/home/erdt-cyber/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winapi-x86_64-pc-windows-gnu-0.4.0/lib` (exit status: 1)
Troubleshooting Steps Tried:
- Confirmed that Visual Studio Build Tools are installed.
- Tried running the terminal as an administrator.
- I tried mscv gnu and llvm and got this :
= note: LINK : fatal error LNK1181: cannot open input file 'Packet.lib'
warning: `pnet_test` (bin "pnet_test") generated 1 warning
error: could not compile `pnet_test` (bin "pnet_test") due to previous error; 1 warning emitted
Caused by:
process didn't exit successfully: `rustc --crate-name pnet_test --edition=2021 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=206 --crate-type
bin --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C metadata=c113a3f6c480f8f2 --out-dir C:\Users\erdt-cyber\Documents\atl_win\target\release\deps -L dependency=C:\Users\erdt-cyber\Documents\atl_win\target\release\deps --extern pnet=C:\Users\erdt-cyber\Documents\atl_win\target\release\deps\libpnet-554e6b6d6eddfb2c.rlib -L native=C:\Users\erdt-cyber\.cargo\registry\src\index.crates.io-6f17d22bba15001f\pnet-0.34.0/lib/x64` (exit code: 1)
Additional Notes:
Please provide guidance on resolving this issue or troubleshooting steps to diagnose it further.