cmd

open cmd with admin rights (Windows 10)

假如想象 提交于 2020-01-13 18:14:32
问题 I have my own python script that manages the IP address on my computer. Mainly it executes the netsh command in the command line (windows 10) which for you must have administrator rights. It is my own computer, I am the administrator and when running the script I am already logged in with my user (Adrian) which is of type administrator. I can`t use the right click and "run as administrator" solution because I am executing my netsh command from my python script. Anybody knows how to get "run

store SID in a variable

怎甘沉沦 提交于 2020-01-13 11:29:20
问题 I need a way to store the current user's SID in a variable, I tried a lot of variants of: setlocal enableextensions for /f "tokens=*" %%a in ( '"wmic path win32_useraccount where name='%UserName%' get sid"' ) do ( if not "%%a"=="" set myvar=%%a echo/%%myvar%%=%myvar% pause endlocal None are working. wmic path win32_useraccount where name='%UserName%' get sid should be returning 3 lines, and I need the second one stored in a variable. Can someone fix my script? Edit : I am using a .cmd file.

VBScript for creating a scheduled task

南楼画角 提交于 2020-01-13 09:40:19
问题 I'm trying to create a VBScript that creates a batch file then creates a scheduled task to run the batch file. So far everything I've tried creates the batch file, but does not create the scheduled task and I haven't received any errors. Here is what I have so far: Option Explicit Dim objFSO, outFile, wShell Set objFSO = CreateObject("Scripting.FileSystemObject") Set outFile = objFSO.CreateTextFile("C:\test.bat", True) outFile.WriteLine "Start www.google.com" outFile.Close Set wShell =

Is it possible to attach a non-console Win32 application to the invoking cmd shell?

浪子不回头ぞ 提交于 2020-01-13 09:36:15
问题 When I have a Win32 non-console application (AFAIK, the console-ness of a Win32 app is linked into the exe), starting it from the console cmd.exe will return to the command prompt immediately, running the application "in the background" (o.c. it can have a GUI of sorts, or even open its own console window) Is it possible in the non-console executable to detect that it was launched from cmd.exe and "attach" it to the launching cmd.exe? And note that there are various questions/answers related

How to FINDSTR seek an occurrence within a numerical range specified in all TXT in the directory?

不羁的心 提交于 2020-01-13 07:30:11
问题 How do I get "FINDSTR" find a value between a specified range ? I set the "string": "20141001" and "20141030" . If within the *.TXT file exists "20141017", should return the "ERRORLEVEL" = 0. EXEMPLE: @echo off SET DATE_STA=20141001 SET DATE_END=20141030 echo Looking for all the files in the folder echo within the range from %DATE_STA% to %DATA_END% ... echo. :FINDING findstr /r "%DATE_STA% to %DATA_END%" C:\Folder\*.txt IF %ERRORLEVEL%==0 ( goto OKAY) else ( goto FAIL ) :OKAY cls echo. echo

Piping and Command Line arguments

夙愿已清 提交于 2020-01-13 05:53:30
问题 The problem has been solved, the code re-write is as follows: #include <iostream> #include <string> #include <vector> int main(int argc, char** argv){ std::string input; std::vector<std::string> inputVector; while(std::getline( std::cin, input ) ){ inputVector.push_back(input); } for(int i = 0; i < inputVector.size(); i++){ std::cout << i << " of " << inputVector.size()-1 << " is " << inputVector[i] << "\n"; } return 0; } As a slight aside, the output is different in CMD and in Powershell

How to execute command on cmd from C# [closed]

半城伤御伤魂 提交于 2020-01-13 02:40:49
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I want to run commands on the cmd from my C# app. I tried: string strCmdText = "ipconfig"; System.Diagnostics.Process.Start("CMD.exe", strCmdText); result: the cmd window pop but the command didn't do nothing. why? 回答1: Use System.Diagnostics.Process.Start("CMD.exe", "/C ipconfig"); If you want to have cmd still

stop gulp from changing shell/cmd title name

允我心安 提交于 2020-01-12 07:27:33
问题 When gulp is called the it changes my cmd (windows) title to: "gulp" I want the window name to stay as it was I know I can use https://www.npmjs.com/package/gulp-shell but this seems like an overkill I mean that if I call batch script title mytitle gulp . the window's title is "gulp" and not "mytitle" 回答1: Use process.title as stated in this issue : concat process.title instead of overwrite. You shoud use process.cwd() to get the directory where the gulpfile is running. somewhere in your

Opening/Closing application via .bat file [Windows]

隐身守侯 提交于 2020-01-12 05:09:46
问题 Good Day, I have a .bat file that run a specific application then after 5 seconds it will close/kill it. I having right now due to it successfully open the application thought when the app opens it will not execute the remaining commands unless I manually close the app. Here is my code: cd "C:\Program Files (x86)\Aspera\Point-to-Point\bin\" asperascp.exe sleep 5 taskkill /IM asperascp.exe /f I also try removing the sleep command. cd "C:\Program Files (x86)\Aspera\Point-to-Point\bin\"

Opening/Closing application via .bat file [Windows]

跟風遠走 提交于 2020-01-12 05:09:27
问题 Good Day, I have a .bat file that run a specific application then after 5 seconds it will close/kill it. I having right now due to it successfully open the application thought when the app opens it will not execute the remaining commands unless I manually close the app. Here is my code: cd "C:\Program Files (x86)\Aspera\Point-to-Point\bin\" asperascp.exe sleep 5 taskkill /IM asperascp.exe /f I also try removing the sleep command. cd "C:\Program Files (x86)\Aspera\Point-to-Point\bin\"