Failed to create startup registy entry to run batch command - windows

I am trying to optimize W7 UI for a laptop with a wide screen by putting the taskbar on the left and making it thin. I managed this a couple of ways the most successfully by restarting UxSms with Task Scheduler and a batch file. This source is what gave me the idea that I could run the batch with Regedit.
The actual question I would like to answer is why the .reg I made merged without error, but didn't create a key that I could find or seem to run anything when the previously mentioned "This source" seems to suggest that it should work. Obviously I made a mistake, but would really like to understand it.
Name of file: ThinTask.reg
REGEDIT4
; #ECHO OFF
; CLS
; REGEDIT.EXE /S "%~f0"
; net stop "UxSms"
; net start "UxSms"
; EXIT
[HKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionRun] "ThinTask"="Succeeded"
The batch I want to run is really just:
net stop "UxSms"
net start "UxSms"
Any ideas on where I went wrong? Thank you for your time any comments, suggestions, or resources are most welcome.

My dumb mistake. Suppose to save it as a .bac not .reg. No wonder the registry didn't know what to do if I'm trying to run it that way and the whole thing is commented out.

Related

Batch file "to many command-line parameters"

So, for Windows 2000, I'm making kind of a program spammer thing. There is another batch file, that, at the end, calls in the program spammer file. The problem I'm having is adding it saying "to many command-line parameters". This is the current code I have to add it to startup.
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v begin-second /t REG_SZ /f /d C:\Documents and Settings\%LOCALUSER%\Desktop\bat script\begin-second.bat
The rest of the script consists of lines like this:
start <EXE file in system32 or WINNT openable by Run>
And there are a few of these "ping" commands serving as a pause in the program for a selectable amount of time:
ping 1.1.1.1 -n 1 -w 1000>nul
Can somebody help me here? The code to add it to the startup throug the registry probably has something wrong with it. When I launch the .bat file, it just spams the programs. I have Registry Editor open, but nothing changes in this directory, the same one the command uses to write the SZ key to the registry, at HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.
I'm kind of a person learning Batch, so it's pretty obvious why I'm having issues. I'm not experienced enough. What I'm looking for is a workaround, or something to fix this "to many parameters" thing. Also, remember, I'm programming this in Windows 2000.
You need to put your data (after the /d) in quotes, or else it will interpret the spaces in the filename as separators between different parameters.

Invalid number of parameters in Batch but not in cmd

I am trying to make a scheduled batch file to run with the volume shadow copy service to copy the outlook.pst file from microsoft outlook.
The commands work properly when i enter them in the command panel but when i setup the same code in a batch file it gives me an invalid number of parameters error in during the second line.
You have to use administrator access on cmd and the batch file for it to even work and i am doing that but i have no clue as to why i get an error only in the batch version but not in cmd?
I found this link helpful.
Its where i found the batch file which simplifies the process incase anyone is wondering.
Heres the code :
CALL MountLatestShadowCopy "C:\MyShadow\"
xcopy /y "C:\MyShadow\Users\%USERNAME%\Documents\Outlookove datoteke\*.pst" "\\hyp\backup"
RMDIR "C:\MyShadow"
pause
Anyone have any ideas as to the cause of my problems? Its supposed to simply copy the .pst file to a server for backup which i will run on a regular schedule.
Outlook is usually the first thing people open when they turn on their computers so i have to use volume shadow copy otherwise getting a copy might be hard on certain computers.
Thanks for the help in advance!

Scheduling automated scripts suite run from schedular

So I tried and tried but couldn't figure out this one for some reason.
how can I run a task from a desired directory instead of System32 directory where cmd.exe is.
so, when I schedule a task and try to run it ..
command prompt suppose to go to "c:\users\aaa\bbb\ccc" and then pass the argument.
Instead, It's starts at c:\Windows\System32 and fails.
Could anybody help me with this please?
I really appreciate it.
Thank you.
EDIT --
so, now I have a run.bat file with following content in it ...
C:\Users\aaa\bbb\ccc\dd (location to my testrunner.bat file)
testrunner.bat Scripts/all.suite website-address ie (command for the task I wanna perform)
net stop schedule (since window is poping up and going away way to fast, I added this to stop it (not working))
type run.bat
#echo off
cd C:\Users\aaa\bbb\ccc\dd
rem this will show all files in dir
rem is the file you're expecting listed?
dir
rem notice how you can make comments with a leading rem(ark)
#echo starting scripts\all.suite
rem you have to change this to have the full path using Windows X:\dir\dir conventions
c:\home\Scripts\all.suite website-address
#echo done running scripts\all.suite website-address
#echo shutting down
net stop schedule
So its still not clear exactly to me your goal. The reason I added the cd c:\... command is that will **C**hange **D**irectory to the path specified.
This is what you need so you can "run a task from a desired directory instead of System32".
Copy everything from the first #echo off to the last net stop and using notepad, paste it into a file, fix command names and paths website-urls, etc, then save that file to c:\temp\testrunner.bat.
Open a cmd.exe window and test that the script works. Just paste c:\temp\testrunner.bat on to cmd-line and hit enter. If that works, then made an entry in the scheduler to run c:\temp\testrunner.bat . I don't know the specifics of running a script for scheduler, so look for clues on the input screen. Is the an option to run 'now'?
If the .bat file doesn't work from the command-line, then you have to fix the file before you try running it in the scheduler. As your command Scripts/all.suite website-address is a little vague, you'll do better to post a new question asking for help to fix the .bat file and use a sample command that people will be able to use on their PCs at home.
IHTH.

BAT File - START not working randomly on some Windows 7 machines

I have a bat file I'm using to start up GoogleChromePortable and open a web page in Kiok mode.
It works great on my machine and 3 others, except for one where it alerts me that the .exe cannot be found i.e. the path set is not working. Here's the code:
#echo off
set path=%path%;"./folder/chromeFolder"
START /b GoogleChromePortable.exe --kiosk "../../../../index.html"
I run this off a usb.
The ../../../../index.html is there because chrome starts 4 layers deep in the folder structure even though GoogleChromePortable is 3 above the Chrome.exe (might not be relevant).
Tested on 1*Windows8(worked), 1*Windows7(worked), 2*WindowsXP(worked) BUT 1*Windows7(Failed).
Error Message:
"Windows cannot find GoogleChromePortable.exe Make sure you typed the address correctly"
I have tried starting the BAT in administrator mode and this still did not work.
I have tried typing this in step by step and it's the
START GoogleChromePortable.exe
that is failing
SOLUTION
Right. Fixed it. No idea why this works so if anyone knows I'd love to know. Instead of the code above I've used:
START %~dp0folder/chrome/GoogleChromePortable.exe --kiosk "../../../../index.html"
and that's it. Any ideas why this works and the other method doesn't on 1 machine?
"3 above IT" - 3 above what?
You appear to be attempting to add ".\folder\chromefolder" to the path - perhaps it might be an idea to add the directory that is "3 above it" so that GoogleChromePortable.exe is also on the path - presumably on your USB.
Mayhap GoogleChromePortable.exe is already on the path on those other machines...
Right. Fixed it. No idea why this works so if anyone knows I'd love to know. Instead of the code above I've used:
START %~dp0folder/chrome/GoogleChromePortable.exe --kiosk "../../../../index.html"
and that's it. Any ideas why this works and the other method doesn't on 1 machine?

How do I make a hibernation batch file?

I'm trying to make a batch file that executes a simple command:
shutdown -h
I've created a shutdown.bat file with that exact line in it, yet when I run it, all it does is spam the command prompt like crazy.
I've looked at batch file sites, #echo off seems popular, but doesn't that just hide output while the commands are executed just the same?
It turns out that adding a change directory command to the root of the drive fixes the problem. The final text that I ended up using in the .bat file was:
cd c:\
shutdown /h
I believe I am very late for this but just in case someone else comes across this.
The issue was indeed with the name of the bat file. You were calling shutdown -h and the bat file was called shutdown.bat hence the bat file was calling itself causing the loop of the command prompts. To fix this you either rename the bat file or specify the directory where shutdown is located.
Would love to say I figured this out but I simply googled it.
The code you need is
%windir%System32rundll32.exe powrprof.dll,SetSuspendState
If you go to start -> run and then type this in it should work.
So if you have hibernate enabled in the poweroptions this should also work in a batch file.
Hope this helped you
Edit:
P.s. click the white little V under the arrows (left of this answer) to accept the answer ;)
For shutdown:
c:\windows\system32\shutdown -s -f -t 00
(or do ...shutdown -p -f).
E.g.: set the time -t 1000 and save and run it.
To abort just c:\windows\system32\shutdown -a in different batch file.
Very important point to note: if you locate this batch file in your startup then it will execute the s/h/r immediately. E.g. you create a logoff batch file and you locate it in startup
it will logoff the pc within the given time/immediately. However, when you hold shift when logging then it will abort the logoff batch file otherwise you pc will logoff again and again. You don't have to do this I am not sure if it works on every PC.
Create a user and try it there in case you could not log in. good luck
For restart:
c:\windows\system32\shutdown -r -t 00
For hibernate:
c:\windows\system32\shutdown /h
Reference: https://www.instructables.com/id/Shutdown-restart-or-hibernate-your-computer-on-a/

Resources