BetaArchive Logo
Navigation Home Screenshots Image Uploader Server Info FTP Servers Wiki Forum RSS Feed Rules Please Donate
UP: 9d, 11h, 53m | CPU: 45% | MEM: 2878MB of 8095MB used
{The community for beta collectors}

Forum rules


Any off topic discussions should go in this forum. Post count is not increased by posting here.
FTP Access status is required to post in this forum. Find out how to get it


Post new topic Reply to topic  [ 6 posts ] 
Author Message
 PostPost subject: Need a bit of help: batch file programming, variables        Posted: Wed Nov 05, 2008 6:49 pm 
Reply with quote
FTP Access
Offline

Joined
Thu Aug 24, 2006 6:28 pm

Posts
352
I'm having a hard time accomplishing a task in Vista. I need to take the contents of "powercfg -GETACTIVESCHEME" and get the guid.

The results of above command: "Power Scheme GUID: c5b8638b-f23c-4b26-9ccc-fea2ebd59bd2 (name of power configuration)"

The words "Power Scheme GUID: " never change, and the GUID right after that is always the same length (but different letters/numbers). The name is different lengths.


I need to take just the GUID and put it in a variable (like %POWER_GUID%) so I can use the variable to create either a scheduled task a few days off or write the var to a batch script, so that I can reset the current power scheme back to default.


Top  Profile
 PostPost subject:        Posted: Wed Nov 05, 2008 6:59 pm 
Reply with quote
Staff
User avatar
Offline

Joined
Wed Apr 11, 2007 2:11 pm

Posts
2607

Location
Germany, Earth

Favourite OS
Windows 10
Code:
SET POWER_GUID = powercfg -GETACTIVESCHEME


This should work, but I am not sure... haven't used batch files for a long time now...

_________________
MS vNext: Windows 10 ESD Database - Windows 10 Build Labs - Windows 10 Update Archive - Office 2016 Version Tracker - Office Downloader


Top  Profile  WWW
 PostPost subject:        Posted: Wed Nov 05, 2008 7:24 pm 
Reply with quote
FTP Access
User avatar
Offline

Joined
Fri Oct 17, 2008 9:51 pm

Posts
127

Location
Germany
This should work:
Code:
powercfg -getactivescheme >temp.txt
for /f "tokens=4" %%i in  (temp.txt) do set POWER_GUID=%%i
del temp.txt
echo %POWER_GUID%


Top  Profile
 PostPost subject:        Posted: Thu Nov 06, 2008 2:17 pm 
Reply with quote
Donator
Offline

Joined
Tue Oct 28, 2008 9:21 pm

Posts
512

Location
The Netherlands

Favourite OS
Win XP build 2419 | Win7 and up
This should work also
Code:
@echo off
powercfg -getactivescheme >%systemdrive%\tmp.dat
set /p Getvar=<%systemdrive%\tmp.dat
del %systemdrive%\tmp.dat
echo.
echo %getvar%
pause



Top  Profile
 PostPost subject:        Posted: Thu Nov 06, 2008 3:21 pm 
Reply with quote
FTP Access
Offline

Joined
Thu Aug 24, 2006 6:28 pm

Posts
352
Daniel's and Whistler_fan's didn't work (it set everything, including the extra text that I didn't need as the variable) but Tilka's did the trick!

I'll be sure to post the whole set of scripts when I'm done. What they do is make a system restore point, create a new power profile for vista/XP which has no power saving options enabled, then disables the screensaver and sets a task in task scheduler to restore the default power profile and delete the new one (as well as create a batch file you can click to do the same). The other scripts I'm working on apply a bunch of tweaks to vista (trust me, finding a way to run elevated commands from a batch file sucked) with a few neat features (such as detecting whether it's 64-bit or not and creating shortcuts from the command line, which also was hard to find).


Maybe not monumental by themselves, but some of the methods I used are really useful.


Top  Profile
 PostPost subject:        Posted: Thu Nov 06, 2008 9:20 pm 
Reply with quote
Donator
Offline

Joined
Tue Oct 28, 2008 9:21 pm

Posts
512

Location
The Netherlands

Favourite OS
Win XP build 2419 | Win7 and up
It's nice to hear that you have your code working. But i didnt know that you only wanted the the GUID, i thougt that you wanted the complete line of text not just the GUID. But it's working now and i have learned an new command today (the FOR command).


Top  Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 




Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.

Powered by phpBB® Forum Software © phpBB Group

Copyright © 2006-2018

 

Sitemap | XML | RSS